Difference between revisions of "User:ElFarto/OpenGLBM"

From OpenGL Wiki
Jump to navigation Jump to search
(This page is no longer needed now we have Vulkan)
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
This is my idea for an new OpenGL API. It's not real, nor is it ever likely to be.<br>
OpenGL Bare Metal is designed to be the thinnest possible layer, while allowing you to fill a GPU's memory and command buffer in a platform independent way. There is no hand holding, it will not go out of it's way to stop you making a mistake or shooting yourself in the foot.<br>
The Playstation 3's libGCM, NVIDIA's bindless extension and the ATI/AMD GPU reference documents have all served as inspiration for this (but mostly libgcm).<br>
=Design Philosophy=
The API is designed to be as thin as possible. It is designed to minimize the amount of information the GPU's driver has to keep around, therefore there are few objects (mainly for sync purposes), the user is expected to keep track of all this information. This simplifies driver development, and helps performance by attempting to avoid cache-misses when binding objects (since the application is in control, it can prefetch upcoming information, where-as the driver can't).<br>
The API gives direct access to the GPU's memory, albeit in an indirect way. Memory addresses are treated as just a regular 64-bit integer, with it starting at 0 and containing BM_MEMORY_SIZE bytes. It was originally designed to have the entire GPU memory mapped into the application, however there are 2 issues with this:
# 32-bit applications on Windows are limited to 2GiB of usable address space. With GPUs coming with > 1GiB of RAM now, this would leave little for the actual application.
# The GPU doesn't know where it's memory is allocated in the application, therefore requiring constant conversion by the application between the mapped address, and the 'local' address (that is, local to the GPU).
The current design side steps both of these problems, and still allows 64-bit applications to map the whole address space if they wish.
There is still an issue of where in memory things can be stored. I've seen hints in the GL_ATI_meminfo extension, that memory is broken up into different regions (VBO, texture, renderbuffer). I'm not sure if this is a limitation of the hardware, or just how the driver manages the memory. For now I'm assuming that any data can be placed in any part of RAM without any problems.
=System Properties=
  int64 memorySize = bmGetInteger64(BM_MEMORY_SIZE);
This method will return the total amount of RAM you may use, in bytes.
  int maxTextureUnits = bmGetInteger(BM_TEXTURE_UNITS);
Returns the amount of texture units. The texture unit range is from 0 to BM_TEXTURE_UNITS-1.
  bmTextureParameters(unit, format, layout, remap, mipmap, dimensions, width, height, depth, pitch, address);
  bmTextureAddressParameters(unit, xwrap, ywrap, zwrap, depthCompare);
  bmTextureFilterParameters(unit, minFilter, maxFilter, maxAnisotropy);
These 3 functions are used to configure a texture unit. Textures are assumed to be continuous in memory with the mipmaps directly following the base layer.
Most of the parameters will make sense, except possibly for layout. There are currently 2 possible values for this:
* LINEAR - The texture is laid out as follows: RGBARGBARGBA... from left-to-right top-to-bottom.
* SWIZZLED - For a description of this, see [http://nouveau.freedesktop.org/wiki/Surface_Layouts here]. I'm not sure it will be called swizzled, since it conflicts with the other texture swizzling.
TODO: anti-aliased textures
  bmColourSurface(index, type, format, width, height, antialiasing, address, pitch);
  bmDepthSurface(type, format, width, height, antialiasing, address, pitch);
These functions are used to configure colour and depth surfaces. These replace both FBOs and the platforms framebuffer.
  bmBlendMode(index, enabled, rgbEquation, srcRGB, dstRGB, alphaEquation, srcAlpha, dstAlpha);
  bmStencilOp(frontStencilFail, frontDepthFail, frontDepthPass, backStencilFail, backDepthFail, backDepthPass);
  bmStencilFunc(frontFunc, frontRef, frontMask, backFunc, backRef, backMask);
  bmDepthFunc(enabled, func);
  bmDepthRange(viewportIndex, near, far);
  bmAlphaFunc(enabled, func, ref);//does hardware still have this?
Blend, Stencil, Depth and Alpha functions. I've tried to condense all of the existing variants into a single call.
  //utility functions
  bmCalculateSize(format, layout, width, height, depth, mipmaps, antialias, *size, *pitch, *alignment); //do we need a separate function for depth?
This function allows the driver to help the application calculate the size, pitch and alignment of a specific texture format.
  anti-aliasing levels (0 = 1 sample, 1 = 2 samples, 2 = 4 samples, 3 = 32x CSAA, etc...)
=vertex arrays=
  bmVertexAttrib(index, components, stride, type, normalise, divisor);
  bmVertexAttribI(index, components, stride, type, divisor);
  bmVertexAttribAddress(index, offset);
  bmElementArray(type, offset);
  bmEnableAttribs(bitmap); //0b101 enables attribute 0 and 2 only
  bmDrawElements(primtype, count, instances, baseVertex, baseInstance);
  bmDrawArrays(primtype, count, instances, baseInstance);
  //indirect functions
  BMShader sh = glCompileShader(shaderType, sourceType, size, *string);
  glGetShaderUCode(sh, &size, &ucodePtr);
  glSetShader(type, offset);
  //functions for getting and setting uniforms
  //functions for shader subroutines
  bmCopyToGPU(void *src, size, int64 dst); //+async version
  bmCopyFromGPU(int64 src, size, void *dst); //+async version
  void* bmMapMemory(int64 mem, size); //+flags
  bmUnmapMemory(void* addr);
  //flush commands
  clear colour/depth/stencil functions
  viewport functions //+indexed versions
  scissor functions
  provoking vertex
  flip page function
  alpha-to-coverage functions
  gpu wait command
  cpu wait command
  vsync wait
  vertex/texture cache invalidation
=transform feedback=
  conditional rendering
=texture parameters=
  format = TEXTURE_R8G8B8A8
  layout = linear | tiled
  remap/component swizzle
  mipmap levels
  dimensions/cubemap/type = 1D, 2D, 3D, CUBEMAP, RECTANGLE
  width/height/depth = setting depth on a 2d texture, makes it a 2d array
  pitch = step from begining of one row to the next
  compressed parameter or part of format?
=texture address parameters=
  x/y/z wrap modes
  depth compare mode
=texture filter parameters=
  min filter
  max filter
=surface parameters=
  type = linear/tiled

Latest revision as of 14:39, 8 March 2015