Commit b602f0dc by Nicolas Capens

Enumerate multisampled EGL configs.

Bug 23535380 Change-Id: I4bc3d9821812253df46262f59d9a55a5802f00b0 Reviewed-on: https://swiftshader-review.googlesource.com/3936Reviewed-by: 's avatarGreg Hartman <ghartman@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com>
parent 3ff330f7
...@@ -143,7 +143,7 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt ...@@ -143,7 +143,7 @@ Config::Config(const DisplayMode &displayMode, EGLint minInterval, EGLint maxInt
| EGL_OPENGL_ES3_BIT | EGL_OPENGL_ES3_BIT
#endif #endif
; ;
mSampleBuffers = multiSample ? 1 : 0; mSampleBuffers = (multiSample > 0) ? 1 : 0;
mSamples = multiSample; mSamples = multiSample;
mSurfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT; mSurfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
mTransparentType = EGL_NONE; mTransparentType = EGL_NONE;
......
...@@ -134,6 +134,13 @@ bool Display::initialize() ...@@ -134,6 +134,13 @@ bool Display::initialize()
mMinSwapInterval = 0; mMinSwapInterval = 0;
mMaxSwapInterval = 4; mMaxSwapInterval = 4;
const int samples[] =
{
0,
2,
4
};
const sw::Format renderTargetFormats[] = const sw::Format renderTargetFormats[] =
{ {
sw::FORMAT_A1R5G5B5, sw::FORMAT_A1R5G5B5,
...@@ -161,19 +168,20 @@ bool Display::initialize() ...@@ -161,19 +168,20 @@ bool Display::initialize()
DisplayMode currentDisplayMode = getDisplayMode(); DisplayMode currentDisplayMode = getDisplayMode();
ConfigSet configSet; ConfigSet configSet;
for(int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(sw::Format); formatIndex++) for(int samplesIndex = 0; samplesIndex < sizeof(samples) / sizeof(int); samplesIndex++)
{ {
sw::Format renderTargetFormat = renderTargetFormats[formatIndex]; for(int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(sw::Format); formatIndex++)
{
for(int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(sw::Format); depthStencilIndex++) sw::Format renderTargetFormat = renderTargetFormats[formatIndex];
{
sw::Format depthStencilFormat = depthStencilFormats[depthStencilIndex];
// FIXME: enumerate multi-sampling for(int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(sw::Format); depthStencilIndex++)
{
sw::Format depthStencilFormat = depthStencilFormats[depthStencilIndex];
configSet.add(currentDisplayMode, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, 0); configSet.add(currentDisplayMode, mMinSwapInterval, mMaxSwapInterval, renderTargetFormat, depthStencilFormat, samples[samplesIndex]);
} }
} }
}
// Give the sorted configs a unique ID and store them internally // Give the sorted configs a unique ID and store them internally
EGLint index = 1; EGLint index = 1;
...@@ -277,22 +285,22 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co ...@@ -277,22 +285,22 @@ EGLSurface Display::createWindowSurface(EGLNativeWindowType window, EGLConfig co
{ {
switch (attribList[0]) switch (attribList[0])
{ {
case EGL_RENDER_BUFFER: case EGL_RENDER_BUFFER:
switch (attribList[1]) switch (attribList[1])
{ {
case EGL_BACK_BUFFER: case EGL_BACK_BUFFER:
break; break;
case EGL_SINGLE_BUFFER: case EGL_SINGLE_BUFFER:
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); // Rendering directly to front buffer not supported return error(EGL_BAD_MATCH, EGL_NO_SURFACE); // Rendering directly to front buffer not supported
default: default:
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
} }
break; break;
case EGL_VG_COLORSPACE: case EGL_VG_COLORSPACE:
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
case EGL_VG_ALPHA_FORMAT: case EGL_VG_ALPHA_FORMAT:
return error(EGL_BAD_MATCH, EGL_NO_SURFACE); return error(EGL_BAD_MATCH, EGL_NO_SURFACE);
default: default:
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE); return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
} }
......
...@@ -83,11 +83,11 @@ bool Surface::initialize() ...@@ -83,11 +83,11 @@ bool Surface::initialize()
{ {
if(libGLES_CM) if(libGLES_CM)
{ {
depthStencil = libGLES_CM->createDepthStencil(width, height, config->mDepthStencilFormat, 1, false); depthStencil = libGLES_CM->createDepthStencil(width, height, config->mDepthStencilFormat, config->mSamples, false);
} }
else if(libGLESv2) else if(libGLESv2)
{ {
depthStencil = libGLESv2->createDepthStencil(width, height, config->mDepthStencilFormat, 1, false); depthStencil = libGLESv2->createDepthStencil(width, height, config->mDepthStencilFormat, config->mSamples, false);
} }
if(!depthStencil) if(!depthStencil)
......
...@@ -75,21 +75,21 @@ protected: ...@@ -75,21 +75,21 @@ protected:
bool reset(int backbufferWidth, int backbufferHeight); bool reset(int backbufferWidth, int backbufferHeight);
const Config *const config; // EGL config surface was created with const Config *const config; // EGL config surface was created with
EGLint height; // Height of surface EGLint height; // Height of surface
EGLint width; // Width of surface EGLint width; // Width of surface
// EGLint horizontalResolution; // Horizontal dot pitch // EGLint horizontalResolution; // Horizontal dot pitch
// EGLint verticalResolution; // Vertical dot pitch // EGLint verticalResolution; // Vertical dot pitch
EGLBoolean largestPBuffer; // If true, create largest pbuffer possible EGLBoolean largestPBuffer; // If true, create largest pbuffer possible
// EGLBoolean mipmapTexture; // True if texture has mipmaps // EGLBoolean mipmapTexture; // True if texture has mipmaps
// EGLint mipmapLevel; // Mipmap level to render to // EGLint mipmapLevel; // Mipmap level to render to
// EGLenum multisampleResolve; // Multisample resolve behavior // EGLenum multisampleResolve; // Multisample resolve behavior
EGLint pixelAspectRatio; // Display aspect ratio EGLint pixelAspectRatio; // Display aspect ratio
EGLenum renderBuffer; // Render buffer EGLenum renderBuffer; // Render buffer
EGLenum swapBehavior; // Buffer swap behavior EGLenum swapBehavior; // Buffer swap behavior
EGLenum textureFormat; // Format of texture: RGB, RGBA, or no texture EGLenum textureFormat; // Format of texture: RGB, RGBA, or no texture
EGLenum textureTarget; // Type of texture: 2D or no texture EGLenum textureTarget; // Type of texture: 2D or no texture
// EGLenum vgAlphaFormat; // Alpha format for OpenVG // EGLenum vgAlphaFormat; // Alpha format for OpenVG
// EGLenum vgColorSpace; // Color space for OpenVG // EGLenum vgColorSpace; // Color space for OpenVG
EGLint swapInterval; EGLint swapInterval;
}; };
......
...@@ -786,7 +786,7 @@ egl::Image *createBackBuffer(int width, int height, const egl::Config *config) ...@@ -786,7 +786,7 @@ egl::Image *createBackBuffer(int width, int height, const egl::Config *config)
{ {
if(config) if(config)
{ {
return new egl::Image(width, height, config->mRenderTargetFormat, 1, false, true); return new egl::Image(width, height, config->mRenderTargetFormat, config->mSamples, false, true);
} }
return 0; return 0;
......
...@@ -1894,7 +1894,7 @@ egl::Image *createBackBuffer(int width, int height, const egl::Config *config) ...@@ -1894,7 +1894,7 @@ egl::Image *createBackBuffer(int width, int height, const egl::Config *config)
{ {
if(config) if(config)
{ {
return new egl::Image(width, height, config->mRenderTargetFormat, 1, false, true); return new egl::Image(width, height, config->mRenderTargetFormat, config->mSamples, false, true);
} }
return 0; return 0;
......
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