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