Commit 101e4f0a by Nicolas Capens

Sort config IDs by smaller color component depth.

This helps select configs without alpha component. Also fixed handling of EGL_DONT_CARE and EGL_BUFFER_SIZE. Bug 21538709 Change-Id: I432a71e5df2a0da19a0c38195edf6c42c2d8b9aa Reviewed-on: https://swiftshader-review.googlesource.com/3370Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent b79fc9f9
...@@ -34,48 +34,44 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt ...@@ -34,48 +34,44 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt
switch (renderTargetFormat) switch (renderTargetFormat)
{ {
case sw::FORMAT_A1R5G5B5: case sw::FORMAT_A1R5G5B5:
mBufferSize = 16;
mRedSize = 5; mRedSize = 5;
mGreenSize = 5; mGreenSize = 5;
mBlueSize = 5; mBlueSize = 5;
mAlphaSize = 1; mAlphaSize = 1;
break; break;
case sw::FORMAT_A2R10G10B10: case sw::FORMAT_A2R10G10B10:
mBufferSize = 32;
mRedSize = 10; mRedSize = 10;
mGreenSize = 10; mGreenSize = 10;
mBlueSize = 10; mBlueSize = 10;
mAlphaSize = 2; mAlphaSize = 2;
break; break;
case sw::FORMAT_A8R8G8B8: case sw::FORMAT_A8R8G8B8:
mBufferSize = 32;
mRedSize = 8; mRedSize = 8;
mGreenSize = 8; mGreenSize = 8;
mBlueSize = 8; mBlueSize = 8;
mAlphaSize = 8; mAlphaSize = 8;
mBindToTextureRGBA = EGL_TRUE; mBindToTextureRGBA = EGL_TRUE;
break; break;
case sw::FORMAT_R5G6B5: case sw::FORMAT_R5G6B5:
mBufferSize = 16;
mRedSize = 5; mRedSize = 5;
mGreenSize = 6; mGreenSize = 6;
mBlueSize = 5; mBlueSize = 5;
mAlphaSize = 0; mAlphaSize = 0;
break; break;
case sw::FORMAT_X8R8G8B8: case sw::FORMAT_X8R8G8B8:
mBufferSize = 32;
mRedSize = 8; mRedSize = 8;
mGreenSize = 8; mGreenSize = 8;
mBlueSize = 8; mBlueSize = 8;
mAlphaSize = 0; mAlphaSize = 0;
mBindToTextureRGB = EGL_TRUE; mBindToTextureRGB = EGL_TRUE;
break; break;
default: default:
UNREACHABLE(); // Other formats should not be valid UNREACHABLE(); // Other formats should not be valid
} }
mLuminanceSize = 0; mLuminanceSize = 0;
mBufferSize = mRedSize + mGreenSize + mBlueSize + mLuminanceSize + mAlphaSize;
mAlphaMaskSize = 0; mAlphaMaskSize = 0;
mColorBufferType = EGL_RGB_BUFFER; mColorBufferType = EGL_RGB_BUFFER;
mConfigCaveat = isSlowConfig() ? EGL_SLOW_CONFIG : EGL_NONE; mConfigCaveat = isSlowConfig() ? EGL_SLOW_CONFIG : EGL_NONE;
...@@ -124,7 +120,7 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt ...@@ -124,7 +120,7 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt
// mDepthSize = 24; // mDepthSize = 24;
// mStencilSize = 8; // mStencilSize = 8;
// break; // break;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
...@@ -167,22 +163,16 @@ bool CompareConfig::operator()(const Config &x, const Config &y) const ...@@ -167,22 +163,16 @@ bool CompareConfig::operator()(const Config &x, const Config &y) const
return x.attribute < y.attribute; \ return x.attribute < y.attribute; \
} }
#define SORT_LARGER(attribute) \
if(x.attribute != y.attribute) \
{ \
return x.attribute > y.attribute; \
}
META_ASSERT(EGL_NONE < EGL_SLOW_CONFIG && EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG); META_ASSERT(EGL_NONE < EGL_SLOW_CONFIG && EGL_SLOW_CONFIG < EGL_NON_CONFORMANT_CONFIG);
SORT_SMALLER(mConfigCaveat); SORT_SMALLER(mConfigCaveat);
META_ASSERT(EGL_RGB_BUFFER < EGL_LUMINANCE_BUFFER); META_ASSERT(EGL_RGB_BUFFER < EGL_LUMINANCE_BUFFER);
SORT_SMALLER(mColorBufferType); SORT_SMALLER(mColorBufferType);
SORT_LARGER(mRedSize); SORT_SMALLER(mRedSize);
SORT_LARGER(mGreenSize); SORT_SMALLER(mGreenSize);
SORT_LARGER(mBlueSize); SORT_SMALLER(mBlueSize);
SORT_LARGER(mAlphaSize); SORT_SMALLER(mAlphaSize);
SORT_SMALLER(mBufferSize); SORT_SMALLER(mBufferSize);
SORT_SMALLER(mSampleBuffers); SORT_SMALLER(mSampleBuffers);
...@@ -193,7 +183,6 @@ bool CompareConfig::operator()(const Config &x, const Config &y) const ...@@ -193,7 +183,6 @@ bool CompareConfig::operator()(const Config &x, const Config &y) const
SORT_SMALLER(mNativeVisualType); SORT_SMALLER(mNativeVisualType);
#undef SORT_SMALLER #undef SORT_SMALLER
#undef SORT_LARGER
// Strict ordering requires sorting all non-equal fields above // Strict ordering requires sorting all non-equal fields above
assert(memcmp(&x, &y, sizeof(Config)) == 0); assert(memcmp(&x, &y, sizeof(Config)) == 0);
...@@ -201,22 +190,22 @@ bool CompareConfig::operator()(const Config &x, const Config &y) const ...@@ -201,22 +190,22 @@ bool CompareConfig::operator()(const Config &x, const Config &y) const
return false; return false;
} }
// Function object used by STL sorting routines for ordering Configs according to [EGL] section 3.4.1 page 24. // Function object used by STL sorting routines for ordering Configs according to [EGL] section 3.4.1 page 24.
class SortConfig class SortConfig
{ {
public: public:
explicit SortConfig(const EGLint *attribList); explicit SortConfig(const EGLint *attribList);
bool operator()(const Config *x, const Config *y) const; bool operator()(const Config *x, const Config *y) const;
private: private:
EGLint wantedComponentsSize(const Config *config) const; EGLint wantedComponentsSize(const Config *config) const;
bool mWantRed; bool mWantRed;
bool mWantGreen; bool mWantGreen;
bool mWantBlue; bool mWantBlue;
bool mWantAlpha; bool mWantAlpha;
bool mWantLuminance; bool mWantLuminance;
}; };
SortConfig::SortConfig(const EGLint *attribList) SortConfig::SortConfig(const EGLint *attribList)
...@@ -318,6 +307,11 @@ bool ConfigSet::getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint ...@@ -318,6 +307,11 @@ bool ConfigSet::getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint
while(attribute[0] != EGL_NONE) while(attribute[0] != EGL_NONE)
{ {
if(attribute[1] == EGL_DONT_CARE)
{
continue;
}
switch(attribute[0]) switch(attribute[0])
{ {
case EGL_BUFFER_SIZE: match = config->mBufferSize >= attribute[1]; break; case EGL_BUFFER_SIZE: match = config->mBufferSize >= attribute[1]; break;
......
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