GFXD3D8Device Class Reference

#include <gfxD3D8Device.h>

Inheritance diagram for GFXD3D8Device:

Inheritance graph
[legend]
List of all members.

Debug Vertex Buffer information/management

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

Public Member Functions

GFXTextureObjectcreateRenderSurface (U32 width, U32 height, GFXFormat format, U32 mipLevel)
 GFXD3D8Device (IDirect3D8 *d3d, U32 index)
 Constructor.
 ~GFXD3D8Device ()
virtual void init (const GFXVideoMode &mode, PlatformWindow *window=NULL)
 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 enterDebugEvent (ColorI color, const char *name)
virtual void leaveDebugEvent ()
virtual void setDebugMarker (ColorI color, const char *name)
void enumerateVideoModes ()
void setVideoMode (const GFXVideoMode &mode)
virtual GFXFormat selectSupportedFormat (GFXTextureProfile *profile, const Vector< GFXFormat > &formats, bool texture, bool mustblend)
void clear (U32 flags, ColorI color, F32 z, U32 stencil)
bool beginSceneInternal ()
void endSceneInternal ()
void setViewport (const RectI &rect)
const RectIgetViewport () const
void setClipRect (const RectI &rect)
const RectIgetClipRect () const
virtual GFXTextureTargetallocRenderToTextureTarget ()
 Allocate a target for doing render to texture operations, with no depth/stencil buffer.
virtual GFXWindowTargetallocWindowTarget (PlatformWindow *window)
 Allocate a target for a given window.
virtual void pushActiveRenderTarget ()
 Save current render target states - note this works with MRT's.
virtual void popActiveRenderTarget ()
 Restore all render targets - supports MRT's.
virtual void setActiveRenderTarget (GFXTarget *target)
 Start rendering to to a specified render target.
virtual GFXTargetgetActiveRenderTarget ()
 Return a pointer to the current active render target.
void setVB (GFXVertexBuffer *buffer)
GFXVertexBufferallocVertexBuffer (U32 numVerts, U32 vertFlags, U32 vertSize, GFXBufferType bufferType)
 This allocates a vertex buffer and returns a pointer to the allocated buffer.
GFXPrimitiveBufferallocPrimitiveBuffer (U32 numIndices, U32 numPrimitives, GFXBufferType bufferType)
 This allocates a primitive buffer and returns a pointer to the allocated buffer.
void deallocVertexBuffer (GFXD3D8VertexBuffer *vertBuff)
void zombifyTextureManager ()
void resurrectTextureManager ()
U32 getMaxDynamicVerts ()
U32 getMaxDynamicIndices ()
void drawPrimitive (GFXPrimitiveType primType, U32 vertexStart, U32 primitiveCount)
IDirect3DDevice8 * getDevice ()
D3DPRESENT_PARAMETERS setupPresentParams (const GFXVideoMode &mode, const HWND &hwnd)
 Device helper function.
void reset (D3DPRESENT_PARAMETERS &d3dpp)
 Reset.
F32 getFillConventionOffset () const
 Get the fill convention for this device.
GFXFencecreateFence ()
 Allocate a fence.

Static Public Member Functions

static GFXDevicecreateInstance (U32 adapterIndex)
static char * getDXVersion ()
 Get a string indicating the installed DirectX version, revision and letter number.
static void enumerateAdapters (Vector< GFXAdapter * > &adapterList)

Static Public Attributes

static D3D8XFNTable smD3DX

Protected Member Functions

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 setTextureInternal (U32 textureUnit, const GFXTextureObject *texture)
virtual void setLightInternal (U32 lightStage, const GFXLightInfo light, bool lightEnable)
virtual void setLightMaterialInternal (const GFXLightMaterial mat)
virtual void setGlobalAmbientInternal (ColorF color)
void setMatrix (GFXMatrixType mtype, const MatrixF &mat)
 This function must be implemented differently per API and it should set ONLY the current matrix.
void initStates ()
 State initialization.
GFXVertexBufferallocVB (U32 numVerts, void **vertexPtr, U32 vertFlags, U32 vertSize)
GFXVertexBufferallocPooledVB (U32 numVerts, void **vertexPtr, U32 vertFlags, U32 vertSize)
GFXPrimitiveBufferallocPB (U32 numIndices, void **indexPtr)
GFXPrimitiveBufferallocPooledPB (U32 numIndices, void **indexPtr)
void setPrimitiveBuffer (GFXPrimitiveBuffer *buffer)
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.

Static Protected Attributes

static GFXAdapter::CreateDeviceInstanceDelegate mCreateDeviceInstance

Private Types

typedef GFXDevice Parent
typedef StrongRefPtr< GFXD3D8VertexBufferRPGDVB

Private Member Functions

virtual void copyBBToSfxBuff ()
 Special effects back buffer - for refraction and other effects.
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.
GFXD3D8VertexBufferfindVBPool (U32 vertFlags)
GFXD3D8VertexBuffercreateVBPool (U32 vertFlags, U32 vertSize)

Static Private Member Functions

static void initD3DXFnTable ()

Private Attributes

MatrixF mTempMatrix
 Temporary matrix, no assurances on value at all.
_D3DVIEWPORT8 * mViewport
 Because setViewport gets called a lot, don't want to allocate/unallocate a lot.
RectI mViewportRect
RectI mClipRect
IDirect3DSurface8 * mDepthStencil
Vector< RPGDVBmVolatileVBList
GFXD3D8VertexBuffermCurrentOpenAllocVB
GFXD3D8VertexBuffermCurrentVB
voidmCurrentOpenAllocVertexData
StrongRefPtr< GFXD3D8PrimitiveBuffermDynamicPB
 Dynamic index buffer.
GFXD3D8PrimitiveBuffermCurrentOpenAllocPB
GFXD3D8PrimitiveBuffermCurrentPB
IDirect3D8 * mD3D
 D3D Handle.
IDirect3DDevice8 * mD3DDevice
 Handle for D3DDevice.
GFXFormat mBackbufferFormat
 Our backbuffer format.
U32 mAdapterIndex
 Adapter index because D3D supports multiple adapters.
GFXD3D8ShaderMgr mShaderMgr
 D3D Shader Manager.
F32 mPixVersion
U32 mNumSamplers

Friends

class GFXD3D8PrimitiveBuffer
class GFXD3D8VertexBuffer
class GFXD3D8TextureObject

Member Typedef Documentation

typedef GFXDevice GFXD3D8Device::Parent [private]


Constructor & Destructor Documentation

GFXD3D8Device::GFXD3D8Device ( IDirect3D8 *  d3d,
U32  index 
)

Constructor.

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

GFXD3D8Device::~GFXD3D8Device (  ) 


Member Function Documentation

static void GFXD3D8Device::initD3DXFnTable (  )  [static, private]

virtual void GFXD3D8Device::copyBBToSfxBuff (  )  [private, virtual]

Special effects back buffer - for refraction and other effects.

Implements GFXDevice.

void GFXD3D8Device::reacquireDefaultPoolResources (  )  [private]

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

void GFXD3D8Device::releaseDefaultPoolResources (  )  [private]

To release all resources we control from D3DPOOL_DEFAULT.

void GFXD3D8Device::regenStates (  )  [private]

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

GFXD3D8VertexBuffer* GFXD3D8Device::findVBPool ( U32  vertFlags  )  [private]

GFXD3D8VertexBuffer* GFXD3D8Device::createVBPool ( U32  vertFlags,
U32  vertSize 
) [private]

void GFXD3D8Device::addVertexBuffer ( GFXD3D8VertexBuffer buffer  )  [private]

void GFXD3D8Device::removeVertexBuffer ( GFXD3D8VertexBuffer buffer  )  [private]

void GFXD3D8Device::logVertexBuffers (  )  [private]

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

Called by GFXDevice to create a device specific stateblock.

Implements GFXDevice.

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

Called by GFXDevice to actually set a stateblock.

Implements GFXDevice.

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

Called by base GFXDevice to actually set a const buffer.

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

void GFXD3D8Device::setMatrix ( GFXMatrixType  mtype,
const MatrixF mat 
) [protected, virtual]

This function must be implemented differently per API and it should set ONLY the current matrix.

For example, in OpenGL, there should be NO matrix stack activity, all the stack stuff is managed in the GFX layer.

OpenGL does not have separate world and view matrices. It has ModelView which is world * view. You must take this into consideration.

Parameters:
mtype Which matrix to set, world/view/projection
mat Matrix to assign

Implements GFXDevice.

void GFXD3D8Device::initStates (  )  [protected, virtual]

State initialization.

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

Implements GFXDevice.

GFXVertexBuffer* GFXD3D8Device::allocVB ( U32  numVerts,
void **  vertexPtr,
U32  vertFlags,
U32  vertSize 
) [protected]

GFXVertexBuffer* GFXD3D8Device::allocPooledVB ( U32  numVerts,
void **  vertexPtr,
U32  vertFlags,
U32  vertSize 
) [protected]

GFXPrimitiveBuffer* GFXD3D8Device::allocPB ( U32  numIndices,
void **  indexPtr 
) [protected]

GFXPrimitiveBuffer* GFXD3D8Device::allocPooledPB ( U32  numIndices,
void **  indexPtr 
) [protected]

void GFXD3D8Device::setPrimitiveBuffer ( GFXPrimitiveBuffer buffer  )  [protected]

Reimplemented from GFXDevice.

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

Implements GFXDevice.

virtual GFXShader* GFXD3D8Device::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.

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

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

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

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

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

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

Implements GFXDevice.

virtual void GFXD3D8Device::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 GFXD3D8Device::getAdapterType (  )  [inline, virtual]

Returns active graphics adapter type.

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

virtual void GFXD3D8Device::disableShaders (  )  [virtual]

Reimplemented from GFXDevice.

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

Reimplemented from GFXDevice.

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

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

Implements GFXDevice.

virtual void GFXD3D8Device::enterDebugEvent ( ColorI  color,
const char *  name 
) [virtual]

Implements GFXDevice.

virtual void GFXD3D8Device::leaveDebugEvent (  )  [virtual]

Implements GFXDevice.

virtual void GFXD3D8Device::setDebugMarker ( ColorI  color,
const char *  name 
) [virtual]

Implements GFXDevice.

void GFXD3D8Device::enumerateVideoModes (  )  [virtual]

Implements GFXDevice.

static void GFXD3D8Device::enumerateAdapters ( Vector< GFXAdapter * > &  adapterList  )  [static]

void GFXD3D8Device::setVideoMode ( const GFXVideoMode mode  ) 

virtual GFXFormat GFXD3D8Device::selectSupportedFormat ( GFXTextureProfile profile,
const Vector< GFXFormat > &  formats,
bool  texture,
bool  mustblend 
) [virtual]

Implements GFXDevice.

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

Implements GFXDevice.

bool GFXD3D8Device::beginSceneInternal (  )  [virtual]

Implements GFXDevice.

void GFXD3D8Device::endSceneInternal (  )  [virtual]

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

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

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

Implements GFXDevice.

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

Allocate a target for a given window.

Implements GFXDevice.

virtual void GFXD3D8Device::pushActiveRenderTarget (  )  [virtual]

Save current render target states - note this works with MRT's.

Reimplemented from GFXDevice.

virtual void GFXD3D8Device::popActiveRenderTarget (  )  [virtual]

Restore all render targets - supports MRT's.

Reimplemented from GFXDevice.

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

Start rendering to to a specified render target.

Implements GFXDevice.

virtual GFXTarget* GFXD3D8Device::getActiveRenderTarget (  )  [virtual]

Return a pointer to the current active render target.

Reimplemented from GFXDevice.

void GFXD3D8Device::setVB ( GFXVertexBuffer buffer  ) 

GFXVertexBuffer* GFXD3D8Device::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.

GFXPrimitiveBuffer* GFXD3D8Device::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.

void GFXD3D8Device::deallocVertexBuffer ( GFXD3D8VertexBuffer vertBuff  ) 

void GFXD3D8Device::zombifyTextureManager (  ) 

void GFXD3D8Device::resurrectTextureManager (  ) 

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

Implements GFXDevice.

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

Implements GFXDevice.

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

Implements GFXDevice.

IDirect3DDevice8* GFXD3D8Device::getDevice (  )  [inline]

D3DPRESENT_PARAMETERS GFXD3D8Device::setupPresentParams ( const GFXVideoMode mode,
const HWND &  hwnd 
)

Device helper function.

void GFXD3D8Device::reset ( D3DPRESENT_PARAMETERS &  d3dpp  ) 

Reset.

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

Get the fill convention for this device.

Implements GFXDevice.

GFXFence* GFXD3D8Device::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.


Friends And Related Function Documentation

friend class GFXD3D8PrimitiveBuffer [friend]

friend class GFXD3D8VertexBuffer [friend]

friend class GFXD3D8TextureObject [friend]


Member Data Documentation

Temporary matrix, no assurances on value at all.

_D3DVIEWPORT8* GFXD3D8Device::mViewport [private]

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

IDirect3DSurface8* GFXD3D8Device::mDepthStencil [private]

IDirect3D8* GFXD3D8Device::mD3D [private]

D3D Handle.

IDirect3DDevice8* GFXD3D8Device::mD3DDevice [private]

Handle for D3DDevice.

Our backbuffer format.

Adapter index because D3D supports multiple adapters.

D3D Shader Manager.

To keep track of how many are allocated and freed.