module Graphics.LambdaCube.RenderSystemCapabilities where

import Data.Set

import Graphics.LambdaCube.Types

data Capabilities
    = RSC_AUTOMIPMAP                    -- ^ Supports generating mipmaps in hardware
    | RSC_BLENDING
    | RSC_ANISOTROPY                    -- ^ Supports anisotropic texture filtering
    | RSC_DOT3                          -- ^ Supports fixed-function DOT3 texture blend
    | RSC_CUBEMAPPING                   -- ^ Supports cube mapping
    | RSC_HWSTENCIL                     -- ^ Supports hardware stencil buffer
    | RSC_VBO                           -- ^ Supports hardware vertex and index buffers
    | RSC_VERTEX_PROGRAM                -- ^ Supports vertex programs (vertex shaders)
    | RSC_FRAGMENT_PROGRAM              -- ^ Supports fragment programs (pixel shaders)
    | RSC_SCISSOR_TEST                  -- ^ Supports performing a scissor test to exclude areas of the screen
    | RSC_TWO_SIDED_STENCIL             -- ^ Supports separate stencil updates for both front and back faces
    | RSC_STENCIL_WRAP                  -- ^ Supports wrapping the stencil value at the range extremeties
    | RSC_HWOCCLUSION                   -- ^ Supports hardware occlusion queries
    | RSC_USER_CLIP_PLANES              -- ^ Supports user clipping planes
    | RSC_VERTEX_FORMAT_UBYTE4          -- ^ Supports the VET_UBYTE4 vertex element type
    | RSC_INFINITE_FAR_PLANE            -- ^ Supports infinite far plane projection
    | RSC_HWRENDER_TO_TEXTURE           -- ^ Supports hardware render-to-texture (bigger than framebuffer)
    | RSC_TEXTURE_FLOAT                 -- ^ Supports float textures and render targets
    | RSC_NON_POWER_OF_2_TEXTURES       -- ^ Supports non-power of two textures
    | RSC_TEXTURE_3D                    -- ^ Supports 3d (volume) textures
    | RSC_POINT_SPRITES                 -- ^ Supports basic point sprite rendering
    | RSC_POINT_EXTENDED_PARAMETERS     -- ^ Supports extra point parameters (minsize, maxsize, attenuation)
    | RSC_VERTEX_TEXTURE_FETCH          -- ^ Supports vertex texture fetch
    | RSC_MIPMAP_LOD_BIAS               -- ^ Supports mipmap LOD biasing
    | RSC_GEOMETRY_PROGRAM              -- ^ Supports hardware geometry programs
    | RSC_HWRENDER_TO_VERTEX_BUFFER     -- ^ Supports rendering to vertex buffers

    | RSC_TEXTURE_COMPRESSION           -- ^ Supports compressed textures
    | RSC_TEXTURE_COMPRESSION_DXT       -- ^ Supports compressed textures in the DXT/ST3C formats
    | RSC_TEXTURE_COMPRESSION_VTC       -- ^ Supports compressed textures in the VTC format
    | RSC_TEXTURE_COMPRESSION_PVRTC     -- ^ Supports compressed textures in the PVRTC format
    | RSC_FIXED_FUNCTION                -- ^ Supports fixed-function pipeline
    | RSC_MRT_DIFFERENT_BIT_DEPTHS      -- ^ Supports MRTs with different bit depths
    | RSC_ALPHA_TO_COVERAGE             -- ^ Supports Alpha to Coverage (A2C)
    | RSC_ADVANCED_BLEND_OPERATIONS     -- ^ Supports Blending operations other than +

    | RSC_PERSTAGECONSTANT              -- ^ Is DirectX feature "per stage constants" supported

    | RSC_GL1_5_NOVBO                   -- ^ Supports openGL GLEW version 1.5
    | RSC_FBO                           -- ^ Support for Frame Buffer Objects (FBOs)
    | RSC_FBO_ARB                       -- ^ Support for Frame Buffer Objects ARB implementation (regular FBO is higher precedence)
    | RSC_FBO_ATI                       -- ^ Support for Frame Buffer Objects ATI implementation (ARB FBO is higher precedence)
    | RSC_PBUFFER                       -- ^ Support for PBuffer
    | RSC_GL1_5_NOHWOCCLUSION           -- ^ Support for GL 1.5 but without HW occlusion workaround
    | RSC_POINT_EXTENDED_PARAMETERS_ARB -- ^ Support for point parameters ARB implementation
    | RSC_POINT_EXTENDED_PARAMETERS_EXT -- ^ Support for point parameters EXT implementation
    deriving (Eq,Ord)

data DriverVersion
    = DriverVersion
    { dvMajor   :: Int
    , dvMinor   :: Int
    , dvRelease :: Int
    , dvBuild   :: Int
    }
    deriving Eq

-- | Enumeration of GPU vendors.
data GPUVendor
    = GPU_UNKNOWN
    | GPU_NVIDIA
    | GPU_ATI
    | GPU_INTEL
    | GPU_S3
    | GPU_MATROX
    | GPU_3DLABS
    | GPU_SIS
    | GPU_IMAGINATION_TECHNOLOGIES
    | GPU_APPLE -- ^ Apple Software Renderer
    deriving Eq

data RenderSystemCapabilities
    = RenderSystemCapabilities
    { rscDriverVersion                      :: DriverVersion
    , rscVendor                             :: GPUVendor        -- ^ GPU Vendor

    , rscNumTextureUnits                    :: Int              -- ^ The number of texture units available
    , rscStencilBufferBitDepth              :: Int              -- ^ The stencil buffer bit depth
    , rscCapabilities                       :: Set Capabilities -- ^ Stores the capabilities flags.

    , rscDeviceName                         :: String           -- ^ The name of the device as reported by the render system
    , rscRenderSystemName                   :: String           -- ^ The identifier associated with the render system for which these capabilities are valid

    , rscVertexProgramConstantFloatCount    :: Int              -- ^ The number of floating-point constants vertex programs support
    , rscVertexProgramConstantIntCount      :: Int              -- ^ The number of integer constants vertex programs support
    , rscVertexProgramConstantBoolCount     :: Int              -- ^ The number of boolean constants vertex programs support
    , rscGeometryProgramConstantFloatCount  :: Int              -- ^ The number of floating-point constants geometry programs support
    , rscGeometryProgramConstantIntCount    :: Int              -- ^ The number of integer constants vertex geometry support
    , rscGeometryProgramConstantBoolCount   :: Int              -- ^ The number of boolean constants vertex geometry support
    , rscFragmentProgramConstantFloatCount  :: Int              -- ^ The number of floating-point constants fragment programs support
    , rscFragmentProgramConstantIntCount    :: Int              -- ^ The number of integer constants fragment programs support
    , rscFragmentProgramConstantBoolCount   :: Int              -- ^ The number of boolean constants fragment programs support
    , rscNumMultiRenderTargets              :: Int              -- ^ The number of simultaneous render targets supported
    , rscMaxPointSize                       :: FloatType        -- ^ The maximum point size
    , rscNonPOW2TexturesLimited             :: Bool             -- ^ Are non-POW2 textures feature-limited?
    , rscNumVertexTextureUnits              :: Int              -- ^ The number of vertex texture units supported
    , rscVertexTextureUnitsShared           :: Bool             -- ^ Are vertex texture units shared with fragment processor?
    , rscGeometryProgramNumOutputVertices   :: Int              -- ^ The number of vertices a geometry program can emit in a single run

    , rscSupportedShaderProfiles            :: Set String       -- ^ The list of supported shader profiles
    }