Thursday, October 20, 2011

Direct3D - DirectX

Direct3D uses hardware to perform advanced graphics computing, including z-buffering, anti-aliasing, alpha blending, mipmapping, atmospheric effects, and perspective-correct texture mapping, if it is available on the graphics card. It offers full vertex software emulation but no pixel software emulation for features not available in hardware.

The aim of Direct3D is to abstract the communication between a graphics application and the graphics hardware drivers. It provides a low-level interface to every video card 3D function (e.g. transformations, clipping, lighting, materials, textures, depth buffering). It is presented like a thin abstract layer at a level comparable to GDI.

History
Direct3D 8.0 introduced programmability in the form of vertex and pixel shaders. Its programmable shading capabilities were the first major departure from an OpenGL-style fixed-function architecture, where drawing is controlled by a complicated state machine. Direct3D 8 contained many powerful 3D graphics features, such as vertex shaders, pixel shaders, fog, bump mapping and texture mapping.

Direct3D 9.0 added a new version of the High Level Shader Language, support for floating-point texture formats, Multiple Render Targets (MRT), and texture lookups in the vertex shader.

HLSL is analogous to the GLSL shading language used with the OpenGL standard. It is the same as the Nvidia Cg shading language.

Direct3D 10 defines a minimum standard of hardware capabilities which must be supported for a display system to be "Direct3D 10 compatible". The API features an updated shader model 4.0 and optional interruptibility for shader programs. In addition to the previously available shader stages, the API includes a geometry shader stage that breaks the old model of one vertex in/one vertex out.

HLSL programs come in three forms, vertex shaders, geometry shaders, and pixel (or fragment) shaders. A vertex shader is executed for each vertex that is submitted by the application, and is primarily responsible for transforming the vertex from object space to view space, generating texture coordinates, and calculating lighting coefficients such as the vertex's tangent, binormal and normal vectors. Optionally , geometry shader takes as its input the three vertices of a triangle and uses this data to generate (or tessellate) additional triangles, which are each then sent to the rasterizer. Group of vertices (normally 3, to form a triangle) come through the vertex shader, their output position is interpolated to form pixels within its area; this process is known as rasterisation. Each of these pixels comes through the pixel shader, whereby the resultant screen colour is calculated.

Direct3D 10 features:
  • Programmable pipelines (often referred to as unified pipeline architecture)
  • New state object to enable (mostly) the CPU to change states efficiently
  • Shader model 4.0 adds instructions for integer and bitwise calculations
  • Geometry shaders, which work on adjacent triangles which form a mesh
  • Texture arrays enable swapping of textures in GPU without CPU intervention
  • Rapid occlusion culling - prevents objects from being rendered if it is not visible or too far to be visible
  • Instancing 2.0 support, allowing multiple instances of similar meshes, such as armies, or grass or trees, to be rendered in a single draw call
Direct3D 10.1 features:
  • Finer control over antialiasing (both multisampling and supersampling with per sample shading and application control over sample position)
  • More flexibilities to some of the existing features (cubemap arrays and independent blending modes)
  • hardware must support the following:
  • - Mandatory 32-bit floating point filtering
  • - Mandatory support for 4x anti-aliasing
  • - Shader model 4.1
  • - In 2011, Intel chipsets started supporting Direct3D 10.1 with the introduction of HD graphics 2000 (GMA HD)
Direct3D 11 was released as part of Windows 7, features:
  • Tessellation — to increase at runtime the number of visible polygons from a low detail polygonal model
  • Multithreaded rendering — to render to the same Direct3D device object from different threads for multi core CPUs
  • Compute shaders — which exposes the shader pipeline for non-graphical tasks such as stream processing and physics acceleration, similar in spirit to what OpenCL, Nvidia CUDA, ATI Stream achieves, and HLSL Shader Model 5 among others
  • Two new texture compression algorithms for more efficient packing of high quality and HDR/alpha textures
  • Increased texture cache
Direct3D 11.1 is an update to the API that will initially ship with Windows 8, features:
  • Shader tracing
  • Support for video playback
  • Shader processing of video resources
  • On-the-fly swapping between Direct3D 10 and 11 contexts and feature levels
  • Minor updates to the shader language, such as
  • - larger constant buffers and optional double-precision instructions,
  • - improved blending modes and mandatory support for 16-bit color formats to improve the performance of entry-level GPUs such as Intel HD Graphics