GFXD3D9Device Class Reference

#include <gfxD3D9Device.h>

Inheritance diagram for GFXD3D9Device:

Inheritance graph
[legend]
List of all members.

Debug Vertex Buffer information/management

void addVertexBuffer (GFXD3D9VertexBuffer *buffer)
void removeVertexBuffer (GFXD3D9VertexBuffer *buffer)
void logVertexBuffers ()
U32 mNumAllocatedVertexBuffers
 To keep track of how many are allocated and freed.
GFXD3D9VertexBuffermVBListHead

Public Member Functions

GFXTextureObjectcreateRenderSurface (U32 width, U32 height, GFXFormat format, U32 mipLevel)
 GFXD3D9Device (LPDIRECT3D9 d3d, U32 index)
 Constructor.
virtual ~GFXD3D9Device ()
virtual void init (const GFXVideoMode &mode, PlatformWindow *window=NULL)=0
 Initialize this GFXDevice, optionally specifying a platform window to bind to.
virtual void preDestroy ()
 This is called before this, or any other device, is deleted in the global destroy() method.
GFXAdapterType getAdapterType ()
 Returns active graphics adapter type.
virtual GFXCubemapcreateCubemap ()
virtual F32 getPixelShaderVersion () const
virtual void setPixelShaderVersion (F32 version)
virtual void disableShaders ()
virtual void setShader (GFXShader *shader)
virtual U32 getNumSamplers () const
 Returns the number of texture samplers that can be used in a shader rendering pass.
virtual void clear (U32 flags, ColorI color, F32 z, U32 stencil)
virtual bool beginSceneInternal ()
virtual void endSceneInternal ()
virtual void setViewport (const RectI &rect)
virtual const RectIgetViewport () const
virtual void setClipRect (const RectI &rect)
virtual const RectIgetClipRect () const
void setVB (GFXVertexBuffer *buffer)
virtual GFXVertexBufferallocVertexBuffer (U32 numVerts, U32 vertFlags, U32 vertSize, GFXBufferType bufferType)
 This allocates a vertex buffer and returns a pointer to the allocated buffer.
virtual GFXPrimitiveBufferallocPrimitiveBuffer (U32 numIndices, U32 numPrimitives, GFXBufferType bufferType)
 This allocates a primitive buffer and returns a pointer to the allocated buffer.
virtual void deallocVertexBuffer (GFXD3D9VertexBuffer *vertBuff)
virtual U32 getMaxDynamicVerts ()
virtual U32 getMaxDynamicIndices ()
virtual void drawPrimitive (GFXPrimitiveType primType, U32 vertexStart, U32 primitiveCount)
virtual LPDIRECT3DDEVICE9 getDevice ()
virtual LPDIRECT3D9 getD3D ()
virtual void reset (D3DPRESENT_PARAMETERS &d3dpp)=0
 Reset.
virtual void setupGenericShaders (GenericShaderType type=GSColor)
virtual void destroyD3DResource (IDirect3DResource9 *d3dResource)
virtual F32 getFillConventionOffset () const
 Get the fill convention for this device.
virtual void doParanoidStateCheck ()
GFXFencecreateFence ()
 Allocate a fence.
D3DMULTISAMPLE_TYPE getMultisampleType () const
DWORD getMultisampleLevel () const
Render Targets
virtual GFXWindowTargetallocWindowTarget (PlatformWindow *window)
 Allocate a target for a given window.
virtual GFXTextureTargetallocRenderToTextureTarget ()
 Allocate a target for doing render to texture operations, with no depth/stencil buffer.
virtual void setActiveRenderTarget (GFXTarget *target)
 Start rendering to to a specified render target.

Static Public Member Functions

static GFXDevicecreateInstance (U32 adapterIndex)
static char * getDXVersion ()
 Get a string indicating the installed DirectX version, revision and letter number.

Public Attributes

GFXShadermGenericShader [GS_COUNT]

Static Public Attributes

static D3DXFNTable smD3DX

Protected Types

typedef StrongRefPtr< GFXD3D9VertexBufferRPGDVB

Protected Member Functions

void reacquireDefaultPoolResources ()
 To manage creating and re-creating of these when device is aquired.
void releaseDefaultPoolResources ()
 To release all resources we control from D3DPOOL_DEFAULT.
void regenStates ()
 This you will probably never, ever use, but it is used to generate the code for the initStates() function.
virtual GFXD3D9VertexBufferfindVBPool (U32 vertFlags, U32 numVertsNeeded)
virtual GFXD3D9VertexBuffercreateVBPool (U32 vertFlags, U32 vertSize)
virtual void setTextureInternal (U32 textureUnit, const GFXTextureObject *texture)
virtual GFXStateBlockRef createStateBlockInternal (const GFXStateBlockDesc &desc)
 Called by GFXDevice to create a device specific stateblock.
virtual void setStateBlockInternal (GFXStateBlock *block, bool force)
 Called by GFXDevice to actually set a stateblock.
virtual void setShaderConstBufferInternal (GFXShaderConstBuffer *buffer)
 Called by base GFXDevice to actually set a const buffer.
virtual void setLightInternal (U32 lightStage, const GFXLightInfo light, bool lightEnable)
virtual void setLightMaterialInternal (const GFXLightMaterial mat)
virtual void setGlobalAmbientInternal (ColorF color)
virtual void initStates ()=0
 State initialization.
virtual void _setPrimitiveBuffer (GFXPrimitiveBuffer *buffer)
virtual void drawIndexedPrimitive (GFXPrimitiveType primType, U32 minIndex, U32 numVerts, U32 startIndex, U32 primitiveCount)
virtual GFXShadercreateShader (const char *vertFile, const char *pixFile, F32 pixVersion, const Vector< GFXShaderMacro > &macros)
 Creates a shader.
virtual void destroyShader (GFXShader *shader)
 Destroys shader.
virtual D3DPRESENT_PARAMETERS setupPresentParams (const GFXVideoMode &mode, const HWND &hwnd) const =0
 Device helper function.

Static Protected Member Functions

static void initD3DXFnTable ()

Protected Attributes

MatrixF mTempMatrix
 Temporary matrix, no assurances on value at all.
D3DVIEWPORT9 mViewport
 Because setViewport gets called a lot, don't want to allocate/unallocate a lot.
RectI mViewportRect
RectI mClipRect
Vector< RPGDVBmVolatileVBList
IDirect3DSurface9 * mDeviceBackbuffer
IDirect3DSurface9 * mDeviceDepthStencil
IDirect3DSurface9 * mDeviceColor
GFXD3D9VertexBuffermCurrentOpenAllocVB
GFXD3D9VertexBuffermCurrentVB
voidmCurrentOpenAllocVertexData
StrongRefPtr< GFXD3D9PrimitiveBuffermDynamicPB
 Dynamic index buffer.
GFXD3D9PrimitiveBuffermCurrentOpenAllocPB
GFXD3D9PrimitiveBuffermCurrentPB
IDirect3DVertexShader9 * mLastVertShader
IDirect3DPixelShader9 * mLastPixShader
S32 mCreateFenceType
LPDIRECT3D9 mD3D
 D3D Handle.
LPDIRECT3DDEVICE9 mD3DDevice
 Handle for D3DDevice.
U32 mAdapterIndex
 Adapter index because D3D supports multiple adapters.
GFXD3D9ShaderMgr mShaderMgr
 D3D Shader Manager.
F32 mPixVersion
U32 mNumSamplers
 Profiled (via caps).
D3DMULTISAMPLE_TYPE mMultisampleType
DWORD mMultisampleLevel
StrongRefPtr< GFXD3D9ShaderConstBuffermCurrentConstBuffer
 Track the last const buffer we've used.

Private Types

typedef GFXDevice Parent

Friends

class GFXResource
class GFXD3D9PrimitiveBuffer
class GFXD3D9VertexBuffer
class GFXD3D9TextureObject
class GFXD3D9TextureTarget
class GFXD3D9WindowTarget

Member Typedef Documentation

typedef GFXDevice GFXD3D9Device::Parent [private]

Reimplemented in GFX360Device.


Constructor & Destructor Documentation

GFXD3D9Device::GFXD3D9Device ( LPDIRECT3D9  d3d,
U32  index 
)

Constructor.

Parameters:
d3d Direct3D object to instantiate this device with
index Adapter index since D3D can use multiple graphics adapters

virtual GFXD3D9Device::~GFXD3D9Device (  )  [virtual]


Member Function Documentation

static void GFXD3D9Device::initD3DXFnTable (  )  [static, protected]

void GFXD3D9Device::reacquireDefaultPoolResources (  )  [protected]

To manage creating and re-creating of these when device is aquired.

void GFXD3D9Device::releaseDefaultPoolResources (  )  [protected]

To release all resources we control from D3DPOOL_DEFAULT.

void GFXD3D9Device::regenStates (  )  [protected]

This you will probably never, ever use, but it is used to generate the code for the initStates() function.

virtual GFXD3D9VertexBuffer* GFXD3D9Device::findVBPool ( U32  vertFlags,
U32  numVertsNeeded 
) [protected, virtual]

Reimplemented in GFX360Device.

virtual GFXD3D9VertexBuffer* GFXD3D9Device::createVBPool ( U32  vertFlags,
U32  vertSize 
) [protected, virtual]

Reimplemented in GFX360Device.

void GFXD3D9Device::addVertexBuffer ( GFXD3D9VertexBuffer buffer  )  [protected]

void GFXD3D9Device::removeVertexBuffer ( GFXD3D9VertexBuffer buffer  )  [protected]

void GFXD3D9Device::logVertexBuffers (  )  [protected]

virtual void GFXD3D9Device::setTextureInternal ( U32  textureUnit,
const GFXTextureObject texture 
) [protected, virtual]

Implements GFXDevice.

virtual GFXStateBlockRef GFXD3D9Device::createStateBlockInternal ( const GFXStateBlockDesc desc  )  [protected, virtual]

Called by GFXDevice to create a device specific stateblock.

Implements GFXDevice.

virtual void GFXD3D9Device::setStateBlockInternal ( GFXStateBlock block,
bool  force 
) [protected, virtual]

Called by GFXDevice to actually set a stateblock.

Implements GFXDevice.

virtual void GFXD3D9Device::setShaderConstBufferInternal ( GFXShaderConstBuffer buffer  )  [protected, virtual]

Called by base GFXDevice to actually set a const buffer.

Implements GFXDevice.

virtual void GFXD3D9Device::setLightInternal ( U32  lightStage,
const GFXLightInfo  light,
bool  lightEnable 
) [protected, virtual]

Implements GFXDevice.

virtual void GFXD3D9Device::setLightMaterialInternal ( const GFXLightMaterial  mat  )  [protected, virtual]

Implements GFXDevice.

virtual void GFXD3D9Device::setGlobalAmbientInternal ( ColorF  color  )  [protected, virtual]

Implements GFXDevice.

virtual void GFXD3D9Device::initStates (  )  [protected, pure virtual]

State initialization.

This MUST BE CALLED in setVideoMode after the device is created.

Implements GFXDevice.

Implemented in GFX360Device, and GFXPCD3D9Device.

virtual void GFXD3D9Device::_setPrimitiveBuffer ( GFXPrimitiveBuffer buffer  )  [protected, virtual]

virtual void GFXD3D9Device::drawIndexedPrimitive ( GFXPrimitiveType  primType,
U32  minIndex,
U32  numVerts,
U32  startIndex,
U32  primitiveCount 
) [protected, virtual]

Implements GFXDevice.

virtual GFXShader* GFXD3D9Device::createShader ( const char *  vertFile,
const char *  pixFile,
F32  pixVersion,
const Vector< GFXShaderMacro > &  macros 
) [protected, virtual]

Creates a shader.

Parameters:
vertFile Vertex shader filename
pixFile Pixel shader filename
pixVersion Pixel shader version
macros Macros passed to the shader compiler.

Implements GFXDevice.

virtual void GFXD3D9Device::destroyShader ( GFXShader shader  )  [protected, virtual]

Destroys shader.

Reimplemented from GFXDevice.

virtual D3DPRESENT_PARAMETERS GFXD3D9Device::setupPresentParams ( const GFXVideoMode mode,
const HWND &  hwnd 
) const [protected, pure virtual]

Device helper function.

Implemented in GFXPCD3D9Device.

static GFXDevice* GFXD3D9Device::createInstance ( U32  adapterIndex  )  [static]

Reimplemented in GFXPCD3D9Device.

GFXTextureObject* GFXD3D9Device::createRenderSurface ( U32  width,
U32  height,
GFXFormat  format,
U32  mipLevel 
)

static char* GFXD3D9Device::getDXVersion (  )  [static]

Get a string indicating the installed DirectX version, revision and letter number.

virtual void GFXD3D9Device::init ( const GFXVideoMode mode,
PlatformWindow window = NULL 
) [pure virtual]

Initialize this GFXDevice, optionally specifying a platform window to bind to.

Implements GFXDevice.

Implemented in GFX360Device, and GFXPCD3D9Device.

virtual void GFXD3D9Device::preDestroy (  )  [inline, virtual]

This is called before this, or any other device, is deleted in the global destroy() method.

It allows the device to clean up anything while everything is still valid.

Reimplemented from GFXDevice.

GFXAdapterType GFXD3D9Device::getAdapterType (  )  [inline, virtual]

Returns active graphics adapter type.

Implements GFXDevice.

Reimplemented in GFX360Device.

virtual GFXCubemap* GFXD3D9Device::createCubemap (  )  [virtual]

Implements GFXDevice.

virtual F32 GFXD3D9Device::getPixelShaderVersion (  )  const [inline, virtual]

Implements GFXDevice.

virtual void GFXD3D9Device::setPixelShaderVersion ( F32  version  )  [inline, virtual]

Implements GFXDevice.

virtual void GFXD3D9Device::disableShaders (  )  [virtual]

Reimplemented from GFXDevice.

virtual void GFXD3D9Device::setShader ( GFXShader shader  )  [virtual]

Reimplemented from GFXDevice.

virtual U32 GFXD3D9Device::getNumSamplers (  )  const [inline, virtual]

Returns the number of texture samplers that can be used in a shader rendering pass.

Implements GFXDevice.

virtual void GFXD3D9Device::clear ( U32  flags,
ColorI  color,
F32  z,
U32  stencil 
) [virtual]

Implements GFXDevice.

virtual bool GFXD3D9Device::beginSceneInternal (  )  [virtual]

Implements GFXDevice.

virtual void GFXD3D9Device::endSceneInternal (  )  [virtual]

Implements GFXDevice.

virtual void GFXD3D9Device::setViewport ( const RectI rect  )  [virtual]

Implements GFXDevice.

const RectI & GFXD3D9Device::getViewport (  )  const [inline, virtual]

Implements GFXDevice.

virtual void GFXD3D9Device::setClipRect ( const RectI rect  )  [virtual]

Implements GFXDevice.

const RectI & GFXD3D9Device::getClipRect (  )  const [inline, virtual]

Implements GFXDevice.

virtual GFXWindowTarget* GFXD3D9Device::allocWindowTarget ( PlatformWindow window  )  [virtual]

Allocate a target for a given window.

Implements GFXDevice.

virtual GFXTextureTarget* GFXD3D9Device::allocRenderToTextureTarget (  )  [virtual]

Allocate a target for doing render to texture operations, with no depth/stencil buffer.

Implements GFXDevice.

Reimplemented in GFX360Device.

virtual void GFXD3D9Device::setActiveRenderTarget ( GFXTarget target  )  [virtual]

Start rendering to to a specified render target.

Implements GFXDevice.

Reimplemented in GFX360Device.

void GFXD3D9Device::setVB ( GFXVertexBuffer buffer  ) 

virtual GFXVertexBuffer* GFXD3D9Device::allocVertexBuffer ( U32  numVerts,
U32  vertFlags,
U32  vertSize,
GFXBufferType  bufferType 
) [virtual]

This allocates a vertex buffer and returns a pointer to the allocated buffer.

This function should not be called directly - rather it should be used by the GFXVertexBufferHandle class.

Implements GFXDevice.

virtual GFXPrimitiveBuffer* GFXD3D9Device::allocPrimitiveBuffer ( U32  numIndices,
U32  numPrimitives,
GFXBufferType  bufferType 
) [virtual]

This allocates a primitive buffer and returns a pointer to the allocated buffer.

A primitive buffer's type argument refers to the index data - the primitive data will always be preserved from call to call.

Note:
All index buffers use 16-bit indices.

Implements GFXDevice.

virtual void GFXD3D9Device::deallocVertexBuffer ( GFXD3D9VertexBuffer vertBuff  )  [virtual]

virtual U32 GFXD3D9Device::getMaxDynamicVerts (  )  [inline, virtual]

Implements GFXDevice.

virtual U32 GFXD3D9Device::getMaxDynamicIndices (  )  [inline, virtual]

Implements GFXDevice.

virtual void GFXD3D9Device::drawPrimitive ( GFXPrimitiveType  primType,
U32  vertexStart,
U32  primitiveCount 
) [virtual]

Implements GFXDevice.

virtual LPDIRECT3DDEVICE9 GFXD3D9Device::getDevice (  )  [inline, virtual]

virtual LPDIRECT3D9 GFXD3D9Device::getD3D (  )  [inline, virtual]

virtual void GFXD3D9Device::reset ( D3DPRESENT_PARAMETERS &  d3dpp  )  [pure virtual]

Reset.

Implemented in GFX360Device, and GFXPCD3D9Device.

virtual void GFXD3D9Device::setupGenericShaders ( GenericShaderType  type = GSColor  )  [virtual]

Reimplemented in GFX360Device.

virtual void GFXD3D9Device::destroyD3DResource ( IDirect3DResource9 *  d3dResource  )  [inline, virtual]

Reimplemented in GFX360Device.

virtual F32 GFXD3D9Device::getFillConventionOffset (  )  const [inline, virtual]

Get the fill convention for this device.

Implements GFXDevice.

virtual void GFXD3D9Device::doParanoidStateCheck (  )  [virtual]

Reimplemented from GFXDevice.

GFXFence* GFXD3D9Device::createFence (  )  [virtual]

Allocate a fence.

The API specific implementation of GFXDevice is responsible to make sure that the proper type is used. GFXGeneralFence should work in all cases.

Implements GFXDevice.

D3DMULTISAMPLE_TYPE GFXD3D9Device::getMultisampleType (  )  const [inline]

DWORD GFXD3D9Device::getMultisampleLevel (  )  const [inline]


Friends And Related Function Documentation

friend class GFXResource [friend]

Reimplemented from GFXDevice.

friend class GFXD3D9PrimitiveBuffer [friend]

friend class GFXD3D9VertexBuffer [friend]

friend class GFXD3D9TextureObject [friend]

friend class GFXD3D9TextureTarget [friend]

friend class GFXD3D9WindowTarget [friend]


Member Data Documentation

Temporary matrix, no assurances on value at all.

D3DVIEWPORT9 GFXD3D9Device::mViewport [protected]

Because setViewport gets called a lot, don't want to allocate/unallocate a lot.

IDirect3DSurface9* GFXD3D9Device::mDeviceBackbuffer [protected]

IDirect3DSurface9* GFXD3D9Device::mDeviceDepthStencil [protected]

IDirect3DSurface9* GFXD3D9Device::mDeviceColor [protected]

IDirect3DVertexShader9* GFXD3D9Device::mLastVertShader [protected]

IDirect3DPixelShader9* GFXD3D9Device::mLastPixShader [protected]

LPDIRECT3D9 GFXD3D9Device::mD3D [protected]

D3D Handle.

LPDIRECT3DDEVICE9 GFXD3D9Device::mD3DDevice [protected]

Handle for D3DDevice.

Adapter index because D3D supports multiple adapters.

D3D Shader Manager.

Profiled (via caps).

D3DMULTISAMPLE_TYPE GFXD3D9Device::mMultisampleType [protected]

To keep track of how many are allocated and freed.

Track the last const buffer we've used.

Used to notify new constant buffers that they should send all of their constants up