Enumerate multisampled EGL configs.
Bug 23535380
Change-Id: I4bc3d9821812253df46262f59d9a55a5802f00b0
Reviewed-on: https://swiftshader-review.googlesource.com/3936
Reviewed-by: Greg Hartman <ghartman@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libEGL/Config.cpp b/src/OpenGL/libEGL/Config.cpp
index 0a67187..15e89a2 100644
--- a/src/OpenGL/libEGL/Config.cpp
+++ b/src/OpenGL/libEGL/Config.cpp
@@ -143,7 +143,7 @@
| EGL_OPENGL_ES3_BIT
#endif
;
- mSampleBuffers = multiSample ? 1 : 0;
+ mSampleBuffers = (multiSample > 0) ? 1 : 0;
mSamples = multiSample;
mSurfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
mTransparentType = EGL_NONE;
diff --git a/src/OpenGL/libEGL/Display.cpp b/src/OpenGL/libEGL/Display.cpp
index 2ea5a9f..7579bfe8 100644
--- a/src/OpenGL/libEGL/Display.cpp
+++ b/src/OpenGL/libEGL/Display.cpp
@@ -134,6 +134,13 @@
mMinSwapInterval = 0;
mMaxSwapInterval = 4;
+ const int samples[] =
+ {
+ 0,
+ 2,
+ 4
+ };
+
const sw::Format renderTargetFormats[] =
{
sw::FORMAT_A1R5G5B5,
@@ -161,19 +168,20 @@
DisplayMode currentDisplayMode = getDisplayMode();
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++)
+ {
+ sw::Format renderTargetFormat = renderTargetFormats[formatIndex];
- for(int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(sw::Format); depthStencilIndex++)
- {
- sw::Format depthStencilFormat = depthStencilFormats[depthStencilIndex];
+ for(int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(sw::Format); depthStencilIndex++)
+ {
+ sw::Format depthStencilFormat = depthStencilFormats[depthStencilIndex];
- // FIXME: enumerate multi-sampling
-
- 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
EGLint index = 1;
@@ -277,22 +285,22 @@
{
switch (attribList[0])
{
- case EGL_RENDER_BUFFER:
+ case EGL_RENDER_BUFFER:
switch (attribList[1])
{
- case EGL_BACK_BUFFER:
+ case EGL_BACK_BUFFER:
break;
- case EGL_SINGLE_BUFFER:
+ case EGL_SINGLE_BUFFER:
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);
}
break;
- case EGL_VG_COLORSPACE:
+ case EGL_VG_COLORSPACE:
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);
- default:
+ default:
return error(EGL_BAD_ATTRIBUTE, EGL_NO_SURFACE);
}
diff --git a/src/OpenGL/libEGL/Surface.cpp b/src/OpenGL/libEGL/Surface.cpp
index d36be0d..9654ec2 100644
--- a/src/OpenGL/libEGL/Surface.cpp
+++ b/src/OpenGL/libEGL/Surface.cpp
@@ -83,11 +83,11 @@
{
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)
{
- depthStencil = libGLESv2->createDepthStencil(width, height, config->mDepthStencilFormat, 1, false);
+ depthStencil = libGLESv2->createDepthStencil(width, height, config->mDepthStencilFormat, config->mSamples, false);
}
if(!depthStencil)
diff --git a/src/OpenGL/libEGL/Surface.h b/src/OpenGL/libEGL/Surface.h
index ca734c4..bb91a31 100644
--- a/src/OpenGL/libEGL/Surface.h
+++ b/src/OpenGL/libEGL/Surface.h
@@ -75,21 +75,21 @@
bool reset(int backbufferWidth, int backbufferHeight);
const Config *const config; // EGL config surface was created with
- EGLint height; // Height of surface
- EGLint width; // Width of surface
-// EGLint horizontalResolution; // Horizontal dot pitch
-// EGLint verticalResolution; // Vertical dot pitch
- EGLBoolean largestPBuffer; // If true, create largest pbuffer possible
-// EGLBoolean mipmapTexture; // True if texture has mipmaps
-// EGLint mipmapLevel; // Mipmap level to render to
-// EGLenum multisampleResolve; // Multisample resolve behavior
- EGLint pixelAspectRatio; // Display aspect ratio
- EGLenum renderBuffer; // Render buffer
- EGLenum swapBehavior; // Buffer swap behavior
- EGLenum textureFormat; // Format of texture: RGB, RGBA, or no texture
- EGLenum textureTarget; // Type of texture: 2D or no texture
-// EGLenum vgAlphaFormat; // Alpha format for OpenVG
-// EGLenum vgColorSpace; // Color space for OpenVG
+ EGLint height; // Height of surface
+ EGLint width; // Width of surface
+// EGLint horizontalResolution; // Horizontal dot pitch
+// EGLint verticalResolution; // Vertical dot pitch
+ EGLBoolean largestPBuffer; // If true, create largest pbuffer possible
+// EGLBoolean mipmapTexture; // True if texture has mipmaps
+// EGLint mipmapLevel; // Mipmap level to render to
+// EGLenum multisampleResolve; // Multisample resolve behavior
+ EGLint pixelAspectRatio; // Display aspect ratio
+ EGLenum renderBuffer; // Render buffer
+ EGLenum swapBehavior; // Buffer swap behavior
+ EGLenum textureFormat; // Format of texture: RGB, RGBA, or no texture
+ EGLenum textureTarget; // Type of texture: 2D or no texture
+// EGLenum vgAlphaFormat; // Alpha format for OpenVG
+// EGLenum vgColorSpace; // Color space for OpenVG
EGLint swapInterval;
};
diff --git a/src/OpenGL/libGLES_CM/Texture.cpp b/src/OpenGL/libGLES_CM/Texture.cpp
index 4e97a29..478ab28 100644
--- a/src/OpenGL/libGLES_CM/Texture.cpp
+++ b/src/OpenGL/libGLES_CM/Texture.cpp
@@ -786,7 +786,7 @@
{
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;
diff --git a/src/OpenGL/libGLESv2/Texture.cpp b/src/OpenGL/libGLESv2/Texture.cpp
index de835c4..5148ab1 100644
--- a/src/OpenGL/libGLESv2/Texture.cpp
+++ b/src/OpenGL/libGLESv2/Texture.cpp
@@ -1894,7 +1894,7 @@
{
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;