OpenGL ARB Superbuffers - PowerPoint PPT Presentation

1 / 55
About This Presentation
Title:

OpenGL ARB Superbuffers

Description:

const GLint *properties); GLmemARB glAllocMem2DARB(GLenum format, GLsizei width, ... GLint size, GLmemARB mem, GLuint offset); arraySet must be 0. ... – PowerPoint PPT presentation

Number of Views:70
Avg rating:3.0/5.0
Slides: 56
Provided by: chris409
Category:

less

Transcript and Presenter's Notes

Title: OpenGL ARB Superbuffers


1
OpenGL ARB Superbuffers
  • Rob Mace
  • mace_at_ati.com

2
First Some History
  • When OpenGL 1.0 was created
  • Framebuffer resources were static.
  • Memory for framebuffers, textures, and vertex
    arrays (actually not in 1.0) were all separate
    physical memories.
  • In OpenGL 1.0 the framebuffer was made a window
    system resource, on loan to OpenGL.

3
Graphics Hardware Has Evolved
  • Framebuffer resources are now generally dynamic.
  • The memory used by framebuffers, textures, and
    vertex arrays is now often in a shared set of
    physical memories.

4
Evolving OpenGL
  • Add memory objects that can be used as the memory
    of framebuffers, textures, and vertex arrays.
  • Add framebuffer objects that are GL allocated and
    managed resources.

5
What Functionality Does This Add To OpenGL?
  • A light weight method to change which framebuffer
    is being rendered to.
  • Render to texture.
  • Render to vertex array.
  • Combined with programmable shaders and floating
    point memories the possibilities are endless.

6
Uber Buffers Extensions
  • ARB_uber_buffers
  • ARB_uber_vertex_array
  • ARB_uber_mem_image
  • ARB_swap_buffers

7
ARB_uber_buffers
  • Adds memory objects.
  • Adds framebuffer objects.
  • DRAW_FRAMEBUFFER binding point.
  • READ_FRAMEBUFFER binding point.
  • Memory objects attachable to textures and
    framebuffers.

8
ARB_uber_vertex_array
  • Depends on ARB_uber_buffers.
  • Memory objects attachable to vertex arrays.

9
ARB_mem_image
  • Depends on ARB_uber_buffers.
  • Adds glMemImage and glGetMemImage commands.

10
ARB_swap_buffers
  • Interacts with ARB_uber_buffers, but not
    dependent on it.
  • Adds glSwapBuffers.
  • Adds SWAP_SRC_FRAMEBUFFER and SWAP_DST_FRAMEBUFFER
    binding points.

11
Memory Objects
  • Structured Memory
  • Has defined dimensions.
  • Has defined format.
  • Attachable as the memory of
  • Textures Objects
  • Framebuffers Objects
  • Vertex Arrays

12
Creating Memory Objects
  • GLmemARB glAllocMem1DARB(GLenum format, GLsizei
    width,
  • GLsizei np,
  • const GLint
    properties)
  • GLmemARB glAllocMem2DARB(GLenum format, GLsizei
    width,
  • GLsizei height, GLsizei
    np,
  • const GLint
    properties)
  • GLmemARB glAllocMem3DARB(GLenum format, GLsizei
    width,
  • GLsizei height, GLsizei
    depth,
  • GLsizei np,
  • const GLint properties)

13
Creating Memory Objects (cont.)
  • AllocMem returns a valid memory object handle on
    success.
  • AllocMem returns 0 on failure.
  • format is the internal format of the memory
    object. Uses the same internal format enumerants
    as glTexImage.
  • GL_RGBA8, etc.

14
Memory Object Properties
  • The properties argument of AllocMem is an array
    of property/value pairs.
  • Properties define what the memory object is, and
    how it can be used.

15
Properties Array Example
  • GLint properties GL_MIPMAP_ARB,
    GL_TRUE,
  • GL_TEXTURE_2D,
    GL_TRUE,
  • GL_COLOR_BUFFER_ARB,
    GL_TRUE
  • GLmemARB mem
  • mem glAllocMem2DARB(GL_RGBA8, 256, 256, 3,
    properties)

16
Property Types
  • Structure Properties
  • Capability Properties
  • Allocation Properties
  • Configuration Properties
  • Automatic Properties (Not Settable)

17
Structure Properties
  • GL_MIPMAP_ARB
  • GL_CUBE_MAP_ARB
  • GL_DEPTH_SLICED_ARB

18
Capability Properties
  • GL_COLOR_BUFFER_ARB
  • GL_DEPTH_BUFFER_ARB
  • GL_STENCIL_BUFFER_ARB
  • GL_ACCUMULATION_BUFFER_ARB

19
Capability Properties (cont.)
  • GL_TEXTURE_1D
  • GL_TEXTURE_2D
  • GL_TEXTURE_3D
  • GL_TEXTURE_CUBE_MAP
  • GL_TEXTURE_RECTANGLE_EXT
  • GL_VERTEX_ARRAY

20
Configuration Properties
  • GL_SAMPLES
  • GL_BORDER_ARB
  • GL_ACCESS_PATTERN_ARB
  • GL_PROXY_ARB

21
Allocation Properties
  • GL_MATCH_SIZE_ARB
  • GL_MATCH_COMPONENT_SET_ARB
  • GL_MATCH_COMPONENT_SIZE_ARB
  • GL_MATCH_COMPONENT_TYPE_ARB
  • GL_MATCH_SAMPLES_ARB
  • GL_VALIDATE_ONLY_ARB

22
Automatic Properties
  • GL_MEMORY_DIMENSIONS_ARB
  • GL_MEMORY_WIDTH_ARB
  • GL_MEMORY_HEIGHT_ARB
  • GL_MEMORY_DEPTH_ARB
  • GL_MEMORY_LEVELS_ARB

23
Automatic Properties (cont.)
  • GL_BASE_FORMAT_ARB
  • GL_RED_BITS
  • GL_GREEN_BITS
  • Etc.
  • GL_RED_TYPE_ARB
  • GL_GREEN_TYPE_ARB
  • Etc.

24
Automatic Properties (cont.)
  • GL_IS_BASE_MEM_ARB
  • GL_WINDOW_SYSTEM_ALLOCATED_ARB
  • GL_FLAGGED_FOR_DELETION_ARB

25
Cloning Memory Objects
  • Memory objects can be cloned.
  • Cloning does not copy contents.
  • GLmemARB glCloneMemARB(GLmemARB mem)

26
Proxy Memory Objects
  • Created with GL_PROXY_ARB property set to
    GL_TRUE.
  • Have no storage.
  • Clones of proxy memory objects are real memory
    objects and have storage.

27
Memory Object Structure
  • The structure properties define the structure of
    a memory object.
  • Memory object structure is exposed as a set of
    sub memory objects.

28
Mipmap Structure
Base Memory Object
Mipmap Level Sub Memory Objects
29
Sub Memory Objects
  • Sub memory objects are named selectors that
    select a sub portion of a memory objects memory.
  • Sub memory objects are indivisible from their
    base memory object.

30
Getting Sub Memory Objects
  • GLmemARB glGetSubMemARB(GLmemARB mem,
  • GLenum type,
  • GLuint sub)
  • type is one of
  • GL_MIPMAP_ARB
  • GL_CUBE_MAP_ARB
  • GL_DEPTH_SLICED_ARB
  • sub is type specific.

31
Deleting Memory Objects
  • GLvoid glDeleteMemARB(GLmemARB mem)
  • If a memory objects is not currently attached, it
    is deleted.
  • If it is currently attached, it is flagged for
    deletion.
  • Sub memory objects cannot be deleted. Delete the
    base memory object instead.

32
Attaching Memory Objects To Texture Objects
  • GLvoid glAttachTextureMemARB(GLuint texture,
  • GLenum attachment,
  • GLmemARB mem)
  • texture is a texture object id.
  • attachment must be GL_IMAGES_ARB.
  • mem is the memory object to attach.
  • mem of 0 will detach any attached memory object.

33
Texture Attachment Example
  • GLint properties GL_MIPMAP_ARB,
    GL_TRUE,
  • GL_TEXTURE_2D,
    GL_TRUE,
  • GL_COLOR_BUFFER_ARB,
    GL_TRUE
  • GLmemARB mem
  • GLuint tex
  • mem glAllocMem2DARB(GL_RGBA8, 256, 256, 3,
    properties)
  • glGenTextures(1, tex)
  • glAttachTextureMemARB(tex, GL_IMAGES_ARB, mem)

34
Texture Attachment Notes
  • glTexImage commands work but dimensions and
    internalFormat must match.
  • glTexSubImage commands work.
  • GL_GENERATE_MIPMAP parameter has no effect.
    Instead use
  • GLvoid glMemGenerateMipmapARB(GLmemARB mem,
  • GLuint base)

35
Creating Framebuffer Objects
  • GLuint glCreateFramebufferARB(GLvoid)
  • Framebuffer objects have no buffers when created.
  • Memory objects are attached to buffer attachment
    points in a framebuffer object.

36
Attaching Memory Objects To Framebuffer Objects
  • GLvoid glAttachFramebufferMemARB(GLuint
    framebuffer,
  • GLenum
    attachment,
  • GLmemARB mem)
  • framebuffer is a framebuffer object id.
  • attachment is the buffer to attach mem as.
  • mem is the memory object to attach.
  • mem of 0 will detach any memory object attached
    to attachment.

37
Framebuffer Attachment Points
  • GL_FRONT_LEFT or GL_FRONT
  • GL_FRONT_RIGHT
  • GL_BACK_LEFT or GL_BACK
  • GL_BACK_RIGHT
  • GL_AUX0, GL_AUX1, etc.
  • GL_DEPTH_BUFFER_ARB
  • GL_STENCIL_BUFFER_ARB

38
Framebuffer Attachment Points (cont.)
  • GL_COLOR_SAMPLES_ARB
  • GL_DEPTH_SAMPLES_ARB
  • GL_STENCIL_SAMPLES_ARB
  • GL_ACCUMULATION_BUFFER_ARB

39
Framebuffer Attachment Example
  • GLint properties GL_MIPMAP_ARB,
    GL_TRUE,
  • GL_TEXTURE_2D,
    GL_TRUE,
  • GL_COLOR_BUFFER_ARB,
    GL_TRUE
  • GLmemARB mem
  • GLuint fb
  • mem glAllocMem2DARB(GL_RGBA8, 256, 256, 3,
    properties)
  • fb glCreateFramebufferARB()
  • glAttachFramebufferMemARB(fb, GL_BACK, mem)

40
Binding Framebuffer Objects
  • GLvoid glBindFramebufferARB(GLenum target,
  • uint framebuffer),
  • target can be
  • GL_DRAW_FRAMEBUFFER
  • GL_READ_FRAMEBUFFER
  • framebuffer is a framebuffer object id.
  • framebuffer of 0 binds the original window system
    framebuffer object.

41
Render to Texture Example
  • GLint color_props GL_MIPMAP_ARB,
    GL_TRUE,
  • GL_TEXTURE_2D,
    GL_TRUE,
  • GL_COLOR_BUFFER_ARB,
    GL_TRUE
  • GLint depth_props GL_DEPTH_BUFFER_ARB,
    GL_TRUE
  • GLmemARB color_mem, level_mem, depth_mem
  • GLuint fb
  • GLuint tex

42
Render to Texture Example(cont.)
  • /
  • Create objects
  • /
  • color_mem glAllocMem2DARB(GL_RGBA8,
  • 256, 256, 3,
    color_props)
  • depth_mem glAllocMem2DARB(GL_DEPTH_COMPONENT24,
  • 256, 256, 1,
    depth_props)
  • level_mem glGetSubMemARB(color_mem,
    GL_MIPMAP_ARB, 0)
  • fb glCreateFramebufferARB()
  • glGenTextures(1, tex)

43
Render to Texture Example(cont.)
  • /
  • Make attachments
  • /
  • glAttachFramebufferMemARB(fb, GL_BACK,
    level_mem)
  • glAttachFramebufferMemARB(fb, GL_DEPTH_BUFFER_ARB,
  • depth_mem)
  • glAttachTextureMemARB(tex, GL_IMAGES_ARB,
    color_mem)

44
Render to Texture Example(cont.)
  • glBindFramebufferARB(GL_DRAW_FRAMEBUFFER_ARB,
    fb)
  • glDrawBuffer(GL_BACK)
  • ltrender to the texturegt
  • glBindFramebufferARB(GL_DRAW_FRAMEBUFFER_ARB, 0)
  • glMemGenerateMipmapARB(color_mem, 0)
  • glBindTexture(GL_TEXTURE_2D, tex)
  • ltrender using the texturegt

45
Attaching Memory Objects As Vertex Arrays
  • GLvoid glAttachVertexArrayMemARB(GLuint arraySet,
  • GLenum array,
  • GLint size,
  • GLmemARB mem,
  • GLuint offset)
  • arraySet must be 0.
  • array is the array to attach mem as.
  • size specifies the number of components to use.
  • mem is the memory object to attach.
  • offset is the element offset into the mem.

46
Vertex Array Attachment
  • Element indexing of 1D memory objects is
  • i x
  • Element indexing of 2D memory objects is
  • i y width x

47
Rendering To Vertex Arrays
  • Recommended that GL_MATCH_SIZE property be set to
    GL_MIN or GL_MIN_ELEMENTS_ARB when allocating
    renderable vertex array memory objects.
  • When rendering, draw a small number of
    primitives that touch each vertex to be rendered
    once.

48
Render to Vertex Array Example
  • GLint properties GL_MATCH_SIZE_ARB,
    GL_MIN_ELEMENTS_ARB,
  • GL_VERTEX_ARRAY,
    GL_TRUE,
  • GL_COLOR_BUFFER_ARB,
    GL_TRUE
  • GLmemARB mem
  • GLint width, height
  • GLuint fb
  • /
  • Create objects
  • /
  • mem glAllocMem2DARB(GL_RGBA32F_ARB, 10000, 1,
    3, properties)
  • width glGetMemPropertyARB(mem,
    GL_MEMORY_WIDTH_ARB)
  • height glGetMemPropertyARB(mem,
    GL_MEMORY_HEIGHT_ARB)
  • fb glCreateFramebufferARB()

49
Render to Vertex Array Example (cont.)
  • glAttachFramebufferMemARB(fb, GL_BACK, mem)
  • glBindFramebufferARB(GL_DRAW_FRAMEBUFFER_ARB,
    fb)
  • glDrawBuffer(GL_BACK)
  • ltrender to the vertex arraygt
  • glBindFramebufferARB(GL_DRAW_FRAMEBUFFER_ARB, 0)
  • glAttachVertexArrayMemARB(0, 3,
    GL_VERTEX_ARRAY_ARB,
  • mem, 0)
  • ltrender using the vertex arraygt

50
ARB_SWAP_BUFFERS
  • Adds swap framebuffer binding points
  • GL_SWAP_SRC_FRAMEBUFFER_ARB
  • GL_SWAP_DST_FRAMEBUFFER_ARB
  • Adds
  • GLvoid glSwapBuffersARB(GLvoid)
  • Swaps from the back buffer of the swap src
    framebuffer to the front buffer of the swap dst
    framebuffer.

51
ARB_SWAP_BUFFERS (cont.)
  • Adds framebuffer parameters
  • GL_SWAP_PRESERVE_ARB
  • Preserve back buffer contents on swap.
  • GL_SWAP_SYNC_ARB
  • Synchronize swaps to display.
  • GL_SWAP_INTERVAL_ARB
  • Interval of swaps when synchronized.

52
This Is Not Final
  • The OpenGL ARB superbuffers working groups is
    still working to complete these extensions and
    get final agreement on them.

53
Demos
  • Particle system demos by
  • Dr. Peter Kipfer
  • Computer Graphics Visualization Group, TU
    Munich
  • All particle computations in these demos done
    using GPU. Including
  • Motion
  • Collisions
  • Color
  • Sorting

54
Thanks To
  • The members of the OpenGL ARB superbuffers
    working group.
  • Dr. Peter Kipfer (demos)

55
Questions?
Write a Comment
User Comments (0)
About PowerShow.com