Moves multisample support data to Renderer from Context.

TRAC #21817 Signed-off-by: Daniel Koch git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1342 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 6716a278
......@@ -170,7 +170,6 @@ Context::Context(const egl::Config *config, const gl::Context *shareContext, boo
mSupportsEventQueries = false;
mSupportsOcclusionQueries = false;
mNumCompressedTextureFormats = 0;
mMaxSupportedSamples = 0;
mMaskedClearSavedState = NULL;
markAllStateDirty();
}
......@@ -203,12 +202,6 @@ Context::~Context()
deleteQuery(mQueryMap.begin()->first);
}
while (!mMultiSampleSupport.empty())
{
delete [] mMultiSampleSupport.begin()->second;
mMultiSampleSupport.erase(mMultiSampleSupport.begin());
}
for (int type = 0; type < TEXTURE_TYPE_COUNT; type++)
{
for (int sampler = 0; sampler < MAX_COMBINED_TEXTURE_IMAGE_UNITS_VTF; sampler++)
......@@ -279,32 +272,6 @@ void Context::makeCurrent(egl::Display *display, egl::Surface *surface)
TRACE("MaxTextureDimension=%d, MaxCubeTextureDimension=%d, MaxRenderbufferDimension=%d, MaxTextureLevel=%d, MaxTextureAnisotropy=%f",
mMaxTextureDimension, mMaxCubeTextureDimension, mMaxRenderbufferDimension, mMaxTextureLevel, mMaxTextureAnisotropy);
const D3DFORMAT renderBufferFormats[] =
{
D3DFMT_A8R8G8B8,
D3DFMT_X8R8G8B8,
D3DFMT_R5G6B5,
D3DFMT_D24S8
};
int max = 0;
for (int i = 0; i < sizeof(renderBufferFormats) / sizeof(D3DFORMAT); ++i)
{
bool *multisampleArray = new bool[D3DMULTISAMPLE_16_SAMPLES + 1];
mRenderer->getMultiSampleSupport(renderBufferFormats[i], multisampleArray);
mMultiSampleSupport[renderBufferFormats[i]] = multisampleArray;
for (int j = D3DMULTISAMPLE_16_SAMPLES; j >= 0; --j)
{
if (multisampleArray[j] && j != D3DMULTISAMPLE_NONMASKABLE && j > max)
{
max = j;
}
}
}
mMaxSupportedSamples = max;
mSupportsEventQueries = mRenderer->getEventQuerySupport();
mSupportsOcclusionQueries = mRenderer->getOcclusionQuerySupport();
mSupportsDXT1Textures = mRenderer->getDXT1TextureSupport();
......@@ -3465,31 +3432,12 @@ int Context::getMaximumFragmentUniformVectors() const
int Context::getMaxSupportedSamples() const
{
return mMaxSupportedSamples;
return mRenderer->getMaxSupportedSamples();
}
int Context::getNearestSupportedSamples(D3DFORMAT format, int requested) const
{
if (requested == 0)
{
return requested;
}
std::map<D3DFORMAT, bool *>::const_iterator itr = mMultiSampleSupport.find(format);
if (itr == mMultiSampleSupport.end())
{
return -1;
}
for (int i = requested; i <= D3DMULTISAMPLE_16_SAMPLES; ++i)
{
if (itr->second[i] && i != D3DMULTISAMPLE_NONMASKABLE)
{
return i;
}
}
return -1;
return mRenderer->getNearestSupportedSamples(format, requested);
}
bool Context::supportsEventQueries() const
......
......@@ -627,8 +627,6 @@ class Context
int mMaxCubeTextureDimension;
int mMaxTextureLevel;
float mMaxTextureAnisotropy;
std::map<D3DFORMAT, bool *> mMultiSampleSupport;
GLsizei mMaxSupportedSamples;
bool mSupportsEventQueries;
bool mSupportsOcclusionQueries;
bool mSupportsDXT1Textures;
......
......@@ -47,6 +47,8 @@ Renderer::Renderer(egl::Display *display, HMODULE hModule, HDC hDc): mDc(hDc)
#endif
mDeviceLost = false;
mMaxSupportedSamples = 0;
}
Renderer::~Renderer()
......@@ -94,6 +96,11 @@ Renderer::~Renderer()
mD3d9Module = NULL;
}
while (!mMultiSampleSupport.empty())
{
delete [] mMultiSampleSupport.begin()->second;
mMultiSampleSupport.erase(mMultiSampleSupport.begin());
}
}
EGLint Renderer::initialize()
......@@ -200,6 +207,32 @@ EGLint Renderer::initialize()
mMaxSwapInterval = std::max(mMaxSwapInterval, 4);
}
const D3DFORMAT renderBufferFormats[] =
{
D3DFMT_A8R8G8B8,
D3DFMT_X8R8G8B8,
D3DFMT_R5G6B5,
D3DFMT_D24S8
};
int max = 0;
for (int i = 0; i < sizeof(renderBufferFormats) / sizeof(D3DFORMAT); ++i)
{
bool *multisampleArray = new bool[D3DMULTISAMPLE_16_SAMPLES + 1];
getMultiSampleSupport(renderBufferFormats[i], multisampleArray);
mMultiSampleSupport[renderBufferFormats[i]] = multisampleArray;
for (int j = D3DMULTISAMPLE_16_SAMPLES; j >= 0; --j)
{
if (multisampleArray[j] && j != D3DMULTISAMPLE_NONMASKABLE && j > max)
{
max = j;
}
}
}
mMaxSupportedSamples = max;
static const TCHAR windowName[] = TEXT("AngleHiddenWindow");
static const TCHAR className[] = TEXT("STATIC");
......@@ -804,6 +837,35 @@ int Renderer::getMaxSwapInterval() const
return mMaxSwapInterval;
}
int Renderer::getMaxSupportedSamples() const
{
return mMaxSupportedSamples;
}
int Renderer::getNearestSupportedSamples(D3DFORMAT format, int requested) const
{
if (requested == 0)
{
return requested;
}
std::map<D3DFORMAT, bool *>::const_iterator itr = mMultiSampleSupport.find(format);
if (itr == mMultiSampleSupport.end())
{
return -1;
}
for (int i = requested; i <= D3DMULTISAMPLE_16_SAMPLES; ++i)
{
if (itr->second[i] && i != D3DMULTISAMPLE_NONMASKABLE)
{
return i;
}
}
return -1;
}
D3DPOOL Renderer::getBufferPool(DWORD usage) const
{
if (mD3d9Ex != NULL)
......
......@@ -11,6 +11,7 @@
#define LIBGLESV2_RENDERER_RENDERER_H_
#include <set>
#include <map>
#include <vector>
#define GL_APICALL
......@@ -96,7 +97,6 @@ class Renderer
virtual D3DDEVTYPE getDeviceType() {return mDeviceType;}; // D3D9_REMOVE
virtual bool isD3d9ExDevice() const { return mD3d9Ex != NULL; } // D3D9_REMOVE
virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); // D3D9_REPLACE
virtual bool getDXT1TextureSupport();
virtual bool getDXT3TextureSupport();
virtual bool getDXT5TextureSupport();
......@@ -123,12 +123,17 @@ class Renderer
virtual int getMinSwapInterval() const;
virtual int getMaxSwapInterval() const;
virtual GLsizei getMaxSupportedSamples() const;
virtual int getNearestSupportedSamples(D3DFORMAT format, int requested) const;
virtual D3DPOOL getBufferPool(DWORD usage) const;
virtual D3DPOOL getTexturePool(DWORD usage) const;
private:
DISALLOW_COPY_AND_ASSIGN(Renderer);
void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); // D3D9_REPLACE
egl::Display *mDisplay;
const HDC mDc;
HMODULE mD3d9Module;
......@@ -156,6 +161,9 @@ class Renderer
int mMinSwapInterval;
int mMaxSwapInterval;
std::map<D3DFORMAT, bool *> mMultiSampleSupport;
GLsizei mMaxSupportedSamples;
// A pool of event queries that are currently unused.
std::vector<IDirect3DQuery9*> mEventQueryPool;
VertexShaderCache mVertexShaderCache;
......
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