Eliminates redundant calls to GetDeviceCaps

TRAC #12283 Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/trunk@339 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 8187fa8f
......@@ -60,15 +60,14 @@ bool Display::initialize()
// UNIMPLEMENTED(); // FIXME: Determine which adapter index the device context corresponds to
}
D3DCAPS9 caps;
HRESULT result = mD3d9->GetDeviceCaps(mAdapter, mDeviceType, &caps);
HRESULT result = mD3d9->GetDeviceCaps(mAdapter, mDeviceType, &mDeviceCaps);
if (result == D3DERR_OUTOFVIDEOMEMORY || result == E_OUTOFMEMORY)
{
return error(EGL_BAD_ALLOC, false);
}
if (caps.PixelShaderVersion < D3DPS_VERSION(2, 0))
if (mDeviceCaps.PixelShaderVersion < D3DPS_VERSION(2, 0))
{
mD3d9->Release();
mD3d9 = NULL;
......@@ -78,11 +77,11 @@ bool Display::initialize()
mMinSwapInterval = 4;
mMaxSwapInterval = 0;
if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) {mMinSwapInterval = std::min(mMinSwapInterval, 0); mMaxSwapInterval = std::max(mMaxSwapInterval, 0);}
if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_ONE) {mMinSwapInterval = std::min(mMinSwapInterval, 1); mMaxSwapInterval = std::max(mMaxSwapInterval, 1);}
if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO) {mMinSwapInterval = std::min(mMinSwapInterval, 2); mMaxSwapInterval = std::max(mMaxSwapInterval, 2);}
if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE) {mMinSwapInterval = std::min(mMinSwapInterval, 3); mMaxSwapInterval = std::max(mMaxSwapInterval, 3);}
if (caps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR) {mMinSwapInterval = std::min(mMinSwapInterval, 4); mMaxSwapInterval = std::max(mMaxSwapInterval, 4);}
if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_IMMEDIATE) {mMinSwapInterval = std::min(mMinSwapInterval, 0); mMaxSwapInterval = std::max(mMaxSwapInterval, 0);}
if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_ONE) {mMinSwapInterval = std::min(mMinSwapInterval, 1); mMaxSwapInterval = std::max(mMaxSwapInterval, 1);}
if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_TWO) {mMinSwapInterval = std::min(mMinSwapInterval, 2); mMaxSwapInterval = std::max(mMaxSwapInterval, 2);}
if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_THREE) {mMinSwapInterval = std::min(mMinSwapInterval, 3); mMaxSwapInterval = std::max(mMaxSwapInterval, 3);}
if (mDeviceCaps.PresentationIntervals & D3DPRESENT_INTERVAL_FOUR) {mMinSwapInterval = std::min(mMinSwapInterval, 4); mMaxSwapInterval = std::max(mMaxSwapInterval, 4);}
const D3DFORMAT renderTargetFormats[] =
{
......@@ -464,4 +463,9 @@ IDirect3DDevice9 *Display::getDevice()
{
return mDevice;
}
D3DCAPS9 Display::getDeviceCaps()
{
return mDeviceCaps;
}
}
......@@ -59,6 +59,7 @@ class Display
static DWORD convertInterval(GLint interval);
virtual IDirect3DDevice9 *getDevice();
virtual D3DCAPS9 getDeviceCaps();
private:
DISALLOW_COPY_AND_ASSIGN(Display);
......@@ -68,6 +69,7 @@ class Display
D3DDEVTYPE mDeviceType;
IDirect3D9 *mD3d9;
IDirect3DDevice9 *mDevice;
D3DCAPS9 mDeviceCaps;
bool mSceneStarted;
GLint mSwapInterval;
......
......@@ -222,9 +222,9 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
if (!mHasBeenCurrent)
{
device->GetDeviceCaps(&mDeviceCaps);
mDeviceCaps = display->getDeviceCaps();
mBufferBackEnd = new Dx9BackEnd(device);
mBufferBackEnd = new Dx9BackEnd(this, device);
mVertexDataManager = new VertexDataManager(this, mBufferBackEnd);
mIndexDataManager = new IndexDataManager(this, mBufferBackEnd);
mBlit = new Blit(this);
......@@ -268,11 +268,8 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
{
depthStencil->Release();
}
D3DCAPS9 capabilities;
device->GetDeviceCaps(&capabilities);
if (capabilities.PixelShaderVersion == D3DPS_VERSION(3, 0))
if (mDeviceCaps.PixelShaderVersion == D3DPS_VERSION(3, 0))
{
mPsProfile = "ps_3_0";
mVsProfile = "vs_3_0";
......
......@@ -16,6 +16,7 @@
#include "common/debug.h"
#include "libGLESv2/Context.h"
#include "libGLESv2/main.h"
#include "libGLESv2/geometry/vertexconversion.h"
#include "libGLESv2/geometry/IndexDataManager.h"
......@@ -194,7 +195,7 @@ public:
namespace gl
{
Dx9BackEnd::Dx9BackEnd(IDirect3DDevice9 *d3ddevice)
Dx9BackEnd::Dx9BackEnd(Context *context, IDirect3DDevice9 *d3ddevice)
: mDevice(d3ddevice)
{
mDevice->AddRef();
......@@ -207,18 +208,18 @@ Dx9BackEnd::Dx9BackEnd(IDirect3DDevice9 *d3ddevice)
mStreamFrequency[MAX_VERTEX_ATTRIBS] = STREAM_FREQUENCY_UNINSTANCED;
D3DCAPS9 caps;
mDevice->GetDeviceCaps(&caps);
D3DCAPS9 caps = context->getDeviceCaps();
IDirect3D9 *mD3D;
mDevice->GetDirect3D(&mD3D);
IDirect3D9 *d3dObject;
mDevice->GetDirect3D(&d3dObject);
D3DADAPTER_IDENTIFIER9 ident;
mD3D->GetAdapterIdentifier(caps.AdapterOrdinal, 0, &ident);
mD3D->Release();
d3dObject->GetAdapterIdentifier(caps.AdapterOrdinal, 0, &ident);
d3dObject->Release();
// Instancing is mandatory for all HW with SM3 vertex shaders, but avoid hardware where it does not work.
mUseInstancingForStrideZero = (caps.VertexShaderVersion >= D3DVS_VERSION(3, 0) && ident.VendorId != 0x8086);
mSupportIntIndices = (caps.MaxVertexIndex >= (1 << 16));
checkVertexCaps(caps.DeclTypes);
}
......@@ -230,10 +231,7 @@ Dx9BackEnd::~Dx9BackEnd()
bool Dx9BackEnd::supportIntIndices()
{
D3DCAPS9 caps;
mDevice->GetDeviceCaps(&caps);
return (caps.MaxVertexIndex >= (1 << 16));
return mSupportIntIndices;
}
// Initialise a TranslationInfo
......
......@@ -20,7 +20,7 @@ namespace gl
class Dx9BackEnd : public BufferBackEnd
{
public:
explicit Dx9BackEnd(IDirect3DDevice9 *d3ddevice);
explicit Dx9BackEnd(Context *context, IDirect3DDevice9 *d3ddevice);
~Dx9BackEnd();
virtual bool supportIntIndices();
......@@ -39,6 +39,7 @@ class Dx9BackEnd : public BufferBackEnd
IDirect3DDevice9 *mDevice;
bool mUseInstancingForStrideZero;
bool mSupportIntIndices;
bool mAppliedAttribEnabled[MAX_VERTEX_ATTRIBS];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment