Commit f21a1080 by Geoff Lang

Generate the full EGL configs in the Renderers.

Specify the default framebuffer formats in GL formats but still use BGRA and ANGLEX formats for now. BUG=angle:658 Change-Id: I7192db4ca76ab4b0b42daa43785a7ddd9528a9ca Reviewed-on: https://chromium-review.googlesource.com/239902Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent c7ea21fa
......@@ -23,129 +23,44 @@ namespace egl
{
Config::Config()
: renderTargetFormat(GL_NONE),
depthStencilFormat(GL_NONE),
bufferSize(0),
redSize(0),
greenSize(0),
blueSize(0),
luminanceSize(0),
alphaSize(0),
alphaMaskSize(0),
bindToTextureRGB(EGL_FALSE),
bindToTextureRGBA(EGL_FALSE),
colorBufferType(EGL_NONE),
configCaveat(EGL_NONE),
configID(0),
conformant(0),
depthSize(0),
level(0),
matchNativePixmap(EGL_FALSE),
maxPBufferWidth(0),
maxPBufferHeight(0),
maxPBufferPixels(0),
maxSwapInterval(0),
minSwapInterval(0),
nativeRenderable(EGL_FALSE),
nativeVisualID(0),
nativeVisualType(0),
renderableType(0),
sampleBuffers(0),
samples(0),
stencilSize(0),
surfaceType(0),
transparentType(EGL_NONE),
transparentRedValue(0),
transparentGreenValue(0),
transparentBlueValue(0)
{
}
Config::Config(rx::ConfigDesc desc, EGLint minInterval, EGLint maxInterval, EGLint texWidth, EGLint texHeight)
: renderTargetFormat(desc.renderTargetFormat), depthStencilFormat(desc.depthStencilFormat), multiSample(desc.multiSample)
{
bindToTextureRGB = EGL_FALSE;
bindToTextureRGBA = EGL_FALSE;
switch (desc.renderTargetFormat)
{
case GL_RGB5_A1:
bufferSize = 16;
redSize = 5;
greenSize = 5;
blueSize = 5;
alphaSize = 1;
break;
case GL_BGR5_A1_ANGLEX:
bufferSize = 16;
redSize = 5;
greenSize = 5;
blueSize = 5;
alphaSize = 1;
break;
case GL_RGBA8_OES:
bufferSize = 32;
redSize = 8;
greenSize = 8;
blueSize = 8;
alphaSize = 8;
bindToTextureRGBA = true;
break;
case GL_RGB565:
bufferSize = 16;
redSize = 5;
greenSize = 6;
blueSize = 5;
alphaSize = 0;
break;
case GL_RGB8_OES:
bufferSize = 32;
redSize = 8;
greenSize = 8;
blueSize = 8;
alphaSize = 0;
bindToTextureRGB = true;
break;
case GL_BGRA8_EXT:
bufferSize = 32;
redSize = 8;
greenSize = 8;
blueSize = 8;
alphaSize = 8;
bindToTextureRGBA = true;
break;
default:
UNREACHABLE(); // Other formats should not be valid
}
luminanceSize = 0;
alphaMaskSize = 0;
colorBufferType = EGL_RGB_BUFFER;
configCaveat = (desc.fastConfig) ? EGL_NONE : EGL_SLOW_CONFIG;
configID = 0;
conformant = 0;
switch (desc.depthStencilFormat)
{
case GL_NONE:
depthSize = 0;
stencilSize = 0;
break;
case GL_DEPTH_COMPONENT32_OES:
depthSize = 32;
stencilSize = 0;
break;
case GL_DEPTH24_STENCIL8_OES:
depthSize = 24;
stencilSize = 8;
break;
case GL_DEPTH_COMPONENT24_OES:
depthSize = 24;
stencilSize = 0;
break;
case GL_DEPTH_COMPONENT16:
depthSize = 16;
stencilSize = 0;
break;
default:
UNREACHABLE();
}
level = 0;
matchNativePixmap = EGL_NONE;
maxPBufferWidth = texWidth;
maxPBufferHeight = texHeight;
maxPBufferPixels = texWidth*texHeight;
maxSwapInterval = maxInterval;
minSwapInterval = minInterval;
nativeRenderable = EGL_FALSE;
nativeVisualID = 0;
nativeVisualType = 0;
renderableType = EGL_OPENGL_ES2_BIT;
sampleBuffers = desc.multiSample ? 1 : 0;
samples = desc.multiSample;
surfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
transparentType = EGL_NONE;
transparentRedValue = 0;
transparentGreenValue = 0;
transparentBlueValue = 0;
if (desc.es2Conformant)
{
conformant = EGL_OPENGL_ES2_BIT;
}
if (desc.es3Capable)
{
renderableType |= EGL_OPENGL_ES3_BIT_KHR;
conformant |= EGL_OPENGL_ES3_BIT_KHR;
}
}
EGLint ConfigSet::add(const Config &config)
{
// Set the config's ID to a small number that starts at 1 ([EGL 1.5] section 3.4)
......
......@@ -11,11 +11,12 @@
#ifndef INCLUDE_CONFIG_H_
#define INCLUDE_CONFIG_H_
#include "libANGLE/renderer/Renderer.h"
#include "libANGLE/AttributeMap.h"
#include "common/angleutils.h"
#include <EGL/egl.h>
#include <GLES2/gl2.h>
#include <map>
#include <vector>
......@@ -26,11 +27,9 @@ namespace egl
struct Config
{
Config();
Config(rx::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight);
GLenum renderTargetFormat; // TODO(geofflang): remove this
GLenum depthStencilFormat; // TODO(geofflang): remove this
GLint multiSample; // TODO(geofflang): remove this
EGLint bufferSize; // Depth of the color buffer
EGLint redSize; // Bits of Red in the color buffer
......
......@@ -15,6 +15,7 @@
#include <vector>
#include "libANGLE/Error.h"
#include "libANGLE/Caps.h"
#include "libANGLE/Config.h"
#include "libANGLE/AttributeMap.h"
......
......@@ -54,16 +54,6 @@ struct TranslatedIndexData;
struct Workarounds;
class DisplayImpl;
struct ConfigDesc
{
GLenum renderTargetFormat;
GLenum depthStencilFormat;
GLint multiSample;
bool fastConfig;
bool es2Conformant;
bool es3Capable;
};
class Renderer
{
public:
......
......@@ -165,19 +165,7 @@ void DisplayD3D::terminate()
egl::ConfigSet DisplayD3D::generateConfigs() const
{
ASSERT(mRenderer != nullptr);
EGLint minSwapInterval = mRenderer->getMinSwapInterval();
EGLint maxSwapInterval = mRenderer->getMaxSwapInterval();
EGLint maxTextureSize = mRenderer->getRendererCaps().max2DTextureSize;
std::vector<ConfigDesc> descList = mRenderer->generateConfigs();
egl::ConfigSet configSet;
for (size_t i = 0; i < descList.size(); ++i)
{
configSet.add(egl::Config(descList[i], minSwapInterval, maxSwapInterval, maxTextureSize, maxTextureSize));
}
return configSet;
return mRenderer->generateConfigs();
}
bool DisplayD3D::isDeviceLost() const
......
......@@ -18,6 +18,11 @@
//FIXME(jmadill): std::array is currently prohibited by Chromium style guide
#include <array>
namespace egl
{
class ConfigSet;
}
namespace gl
{
class InfoLog;
......@@ -53,7 +58,7 @@ class RendererD3D : public Renderer
virtual EGLint initialize() = 0;
virtual std::vector<ConfigDesc> generateConfigs() const = 0;
virtual egl::ConfigSet generateConfigs() const = 0;
gl::Error drawArrays(const gl::Data &data,
GLenum mode, GLint first,
......
......@@ -67,18 +67,6 @@ namespace rx
namespace
{
static const DXGI_FORMAT RenderTargetFormats[] =
{
DXGI_FORMAT_B8G8R8A8_UNORM,
DXGI_FORMAT_R8G8B8A8_UNORM
};
static const DXGI_FORMAT DepthStencilFormats[] =
{
DXGI_FORMAT_UNKNOWN,
DXGI_FORMAT_D24_UNORM_S8_UINT,
DXGI_FORMAT_D16_UNORM
};
enum
{
......@@ -462,42 +450,86 @@ void Renderer11::initializeDevice()
markAllStateDirty();
}
std::vector<ConfigDesc> Renderer11::generateConfigs() const
egl::ConfigSet Renderer11::generateConfigs() const
{
std::vector<ConfigDesc> configs;
static const GLenum colorBufferFormats[] =
{
GL_BGRA8_EXT,
GL_RGBA8_OES,
};
unsigned int numRenderFormats = ArraySize(RenderTargetFormats);
unsigned int numDepthFormats = ArraySize(DepthStencilFormats);
static const GLenum depthStencilBufferFormats[] =
{
GL_NONE,
GL_DEPTH24_STENCIL8_OES,
GL_DEPTH_COMPONENT16,
};
const gl::Caps &rendererCaps = getRendererCaps();
const gl::TextureCapsMap &rendererTextureCaps = getRendererTextureCaps();
for (unsigned int formatIndex = 0; formatIndex < numRenderFormats; formatIndex++)
egl::ConfigSet configs;
for (size_t formatIndex = 0; formatIndex < ArraySize(colorBufferFormats); formatIndex++)
{
const d3d11::DXGIFormat &renderTargetFormatInfo = d3d11::GetDXGIFormatInfo(RenderTargetFormats[formatIndex]);
const gl::TextureCaps &renderTargetFormatCaps = getRendererTextureCaps().get(renderTargetFormatInfo.internalFormat);
if (renderTargetFormatCaps.renderable)
GLenum colorBufferInternalFormat = colorBufferFormats[formatIndex];
const gl::TextureCaps &colorBufferFormatCaps = rendererTextureCaps.get(colorBufferInternalFormat);
if (colorBufferFormatCaps.renderable)
{
for (unsigned int depthStencilIndex = 0; depthStencilIndex < numDepthFormats; depthStencilIndex++)
for (size_t depthStencilIndex = 0; depthStencilIndex < ArraySize(depthStencilBufferFormats); depthStencilIndex++)
{
const d3d11::DXGIFormat &depthStencilFormatInfo = d3d11::GetDXGIFormatInfo(DepthStencilFormats[depthStencilIndex]);
const gl::TextureCaps &depthStencilFormatCaps = getRendererTextureCaps().get(depthStencilFormatInfo.internalFormat);
if (depthStencilFormatCaps.renderable || DepthStencilFormats[depthStencilIndex] == DXGI_FORMAT_UNKNOWN)
GLenum depthStencilBufferInternalFormat = depthStencilBufferFormats[depthStencilIndex];
const gl::TextureCaps &depthStencilBufferFormatCaps = rendererTextureCaps.get(depthStencilBufferInternalFormat);
if (depthStencilBufferFormatCaps.renderable || depthStencilBufferInternalFormat == GL_NONE)
{
ConfigDesc newConfig;
newConfig.renderTargetFormat = renderTargetFormatInfo.internalFormat;
newConfig.depthStencilFormat = depthStencilFormatInfo.internalFormat;
newConfig.multiSample = 0; // FIXME: enumerate multi-sampling
newConfig.fastConfig = true; // Assume all DX11 format conversions to be fast
// Before we check mFeatureLevel, we need to ensure that the D3D device has been created.
ASSERT(mDevice != NULL);
newConfig.es2Conformant = (mFeatureLevel >= D3D_FEATURE_LEVEL_10_0);
newConfig.es3Capable = isES3Capable();
configs.push_back(newConfig);
const gl::InternalFormat &colorBufferFormatInfo = gl::GetInternalFormatInfo(colorBufferInternalFormat);
const gl::InternalFormat &depthStencilBufferFormatInfo = gl::GetInternalFormatInfo(depthStencilBufferInternalFormat);
egl::Config config;
config.renderTargetFormat = colorBufferInternalFormat;
config.depthStencilFormat = depthStencilBufferInternalFormat;
config.bufferSize = colorBufferFormatInfo.pixelBytes * 8;
config.redSize = colorBufferFormatInfo.redBits;
config.greenSize = colorBufferFormatInfo.greenBits;
config.blueSize = colorBufferFormatInfo.blueBits;
config.luminanceSize = colorBufferFormatInfo.luminanceBits;
config.alphaSize = colorBufferFormatInfo.alphaBits;
config.alphaMaskSize = 0;
config.bindToTextureRGB = (colorBufferFormatInfo.format == GL_RGB);
config.bindToTextureRGBA = (colorBufferFormatInfo.format == GL_RGBA || colorBufferFormatInfo.format == GL_BGRA_EXT);
config.colorBufferType = EGL_RGB_BUFFER;
config.configCaveat = EGL_NONE;
config.configID = static_cast<EGLint>(configs.size() + 1);
// Can only support a conformant ES2 with feature level greater than 10.0.
config.conformant = (mFeatureLevel >= D3D_FEATURE_LEVEL_10_0) ? (EGL_OPENGL_ES2_BIT | EGL_OPENGL_ES3_BIT_KHR) : EGL_NONE;
config.depthSize = depthStencilBufferFormatInfo.depthBits;
config.level = 0;
config.matchNativePixmap = EGL_NONE;
config.maxPBufferWidth = rendererCaps.max2DTextureSize;
config.maxPBufferHeight = rendererCaps.max2DTextureSize;
config.maxPBufferPixels = rendererCaps.max2DTextureSize * rendererCaps.max2DTextureSize;
config.maxSwapInterval = 4;
config.minSwapInterval = 0;
config.nativeRenderable = EGL_FALSE;
config.nativeVisualID = 0;
config.nativeVisualType = EGL_NONE;
// Can't support ES3 at all without feature level 10.0
config.renderableType = EGL_OPENGL_ES2_BIT | ((mFeatureLevel >= D3D_FEATURE_LEVEL_10_0) ? EGL_OPENGL_ES3_BIT_KHR : 0);
config.sampleBuffers = 0; // FIXME: enumerate multi-sampling
config.samples = 0;
config.stencilSize = depthStencilBufferFormatInfo.stencilBits;
config.surfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
config.transparentType = EGL_NONE;
config.transparentRedValue = 0;
config.transparentGreenValue = 0;
config.transparentBlueValue = 0;
configs.add(config);
}
}
}
}
ASSERT(configs.size() > 0);
return configs;
}
......
......@@ -57,7 +57,7 @@ class Renderer11 : public RendererD3D
virtual EGLint initialize();
virtual bool resetDevice();
std::vector<ConfigDesc> generateConfigs() const override;
egl::ConfigSet generateConfigs() const override;
gl::Error flush() override;
gl::Error finish() override;
......
......@@ -65,29 +65,6 @@
namespace rx
{
static const D3DFORMAT RenderTargetFormats[] =
{
D3DFMT_A1R5G5B5,
// D3DFMT_A2R10G10B10, // The color_ramp conformance test uses ReadPixels with UNSIGNED_BYTE causing it to think that rendering skipped a colour value.
D3DFMT_A8R8G8B8,
D3DFMT_R5G6B5,
// D3DFMT_X1R5G5B5, // Has no compatible OpenGL ES renderbuffer format
D3DFMT_X8R8G8B8
};
static const D3DFORMAT DepthStencilFormats[] =
{
D3DFMT_UNKNOWN,
// D3DFMT_D16_LOCKABLE,
D3DFMT_D32,
// D3DFMT_D15S1,
D3DFMT_D24S8,
D3DFMT_D24X8,
// D3DFMT_D24X4S4,
D3DFMT_D16,
// D3DFMT_D32F_LOCKABLE,
// D3DFMT_D24FS8
};
enum
{
......@@ -432,42 +409,93 @@ D3DPRESENT_PARAMETERS Renderer9::getDefaultPresentParameters()
return presentParameters;
}
std::vector<ConfigDesc> Renderer9::generateConfigs() const
egl::ConfigSet Renderer9::generateConfigs() const
{
std::vector<ConfigDesc> configs;
static const GLenum colorBufferFormats[] =
{
GL_BGR5_A1_ANGLEX,
GL_BGRA8_EXT,
GL_RGB565,
};
static const GLenum depthStencilBufferFormats[] =
{
GL_NONE,
GL_DEPTH_COMPONENT32_OES,
GL_DEPTH24_STENCIL8_OES,
GL_DEPTH_COMPONENT24_OES,
GL_DEPTH_COMPONENT16,
};
const gl::Caps &rendererCaps = getRendererCaps();
const gl::TextureCapsMap &rendererTextureCaps = getRendererTextureCaps();
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
unsigned int numRenderFormats = ArraySize(RenderTargetFormats);
unsigned int numDepthFormats = ArraySize(DepthStencilFormats);
for (unsigned int formatIndex = 0; formatIndex < numRenderFormats; formatIndex++)
egl::ConfigSet configs;
for (size_t formatIndex = 0; formatIndex < ArraySize(colorBufferFormats); formatIndex++)
{
const d3d9::D3DFormat &renderTargetFormatInfo = d3d9::GetD3DFormatInfo(RenderTargetFormats[formatIndex]);
const gl::TextureCaps &renderTargetFormatCaps = getRendererTextureCaps().get(renderTargetFormatInfo.internalFormat);
if (renderTargetFormatCaps.renderable)
GLenum colorBufferInternalFormat = colorBufferFormats[formatIndex];
const gl::TextureCaps &colorBufferFormatCaps = rendererTextureCaps.get(colorBufferInternalFormat);
if (colorBufferFormatCaps.renderable)
{
for (unsigned int depthStencilIndex = 0; depthStencilIndex < numDepthFormats; depthStencilIndex++)
for (size_t depthStencilIndex = 0; depthStencilIndex < ArraySize(depthStencilBufferFormats); depthStencilIndex++)
{
const d3d9::D3DFormat &depthStencilFormatInfo = d3d9::GetD3DFormatInfo(DepthStencilFormats[depthStencilIndex]);
const gl::TextureCaps &depthStencilFormatCaps = getRendererTextureCaps().get(depthStencilFormatInfo.internalFormat);
if (depthStencilFormatCaps.renderable || DepthStencilFormats[depthStencilIndex] == D3DFMT_UNKNOWN)
GLenum depthStencilBufferInternalFormat = depthStencilBufferFormats[depthStencilIndex];
const gl::TextureCaps &depthStencilBufferFormatCaps = rendererTextureCaps.get(depthStencilBufferInternalFormat);
if (depthStencilBufferFormatCaps.renderable || depthStencilBufferInternalFormat == GL_NONE)
{
ConfigDesc newConfig;
newConfig.renderTargetFormat = renderTargetFormatInfo.internalFormat;
newConfig.depthStencilFormat = depthStencilFormatInfo.internalFormat;
newConfig.multiSample = 0; // FIXME: enumerate multi-sampling
newConfig.fastConfig = (currentDisplayMode.Format == RenderTargetFormats[formatIndex]);
newConfig.es2Conformant = true;
newConfig.es3Capable = false;
configs.push_back(newConfig);
const gl::InternalFormat &colorBufferFormatInfo = gl::GetInternalFormatInfo(colorBufferInternalFormat);
const gl::InternalFormat &depthStencilBufferFormatInfo = gl::GetInternalFormatInfo(depthStencilBufferInternalFormat);
const d3d9::TextureFormat &d3d9ColorBufferFormatInfo = d3d9::GetTextureFormatInfo(colorBufferInternalFormat);
egl::Config config;
config.renderTargetFormat = colorBufferInternalFormat;
config.depthStencilFormat = depthStencilBufferInternalFormat;
config.bufferSize = colorBufferFormatInfo.pixelBytes * 8;
config.redSize = colorBufferFormatInfo.redBits;
config.greenSize = colorBufferFormatInfo.greenBits;
config.blueSize = colorBufferFormatInfo.blueBits;
config.luminanceSize = colorBufferFormatInfo.luminanceBits;
config.alphaSize = colorBufferFormatInfo.alphaBits;
config.alphaMaskSize = 0;
config.bindToTextureRGB = (colorBufferFormatInfo.format == GL_RGB);
config.bindToTextureRGBA = (colorBufferFormatInfo.format == GL_RGBA || colorBufferFormatInfo.format == GL_BGRA_EXT);
config.colorBufferType = EGL_RGB_BUFFER;
// Mark as slow if blits to the back-buffer won't be straight forward
config.configCaveat = (currentDisplayMode.Format == d3d9ColorBufferFormatInfo.renderFormat) ? EGL_NONE : EGL_SLOW_CONFIG;
config.configID = static_cast<EGLint>(configs.size() + 1);
config.conformant = EGL_OPENGL_ES2_BIT;
config.depthSize = depthStencilBufferFormatInfo.depthBits;
config.level = 0;
config.matchNativePixmap = EGL_NONE;
config.maxPBufferWidth = rendererCaps.max2DTextureSize;
config.maxPBufferHeight = rendererCaps.max2DTextureSize;
config.maxPBufferPixels = rendererCaps.max2DTextureSize * rendererCaps.max2DTextureSize;
config.maxSwapInterval = mMaxSwapInterval;
config.minSwapInterval = mMinSwapInterval;
config.nativeRenderable = EGL_FALSE;
config.nativeVisualID = 0;
config.nativeVisualType = EGL_NONE;
config.renderableType = EGL_OPENGL_ES2_BIT;
config.sampleBuffers = 0; // FIXME: enumerate multi-sampling
config.samples = 0;
config.stencilSize = depthStencilBufferFormatInfo.stencilBits;
config.surfaceType = EGL_PBUFFER_BIT | EGL_WINDOW_BIT | EGL_SWAP_BEHAVIOR_PRESERVED_BIT;
config.transparentType = EGL_NONE;
config.transparentRedValue = 0;
config.transparentGreenValue = 0;
config.transparentBlueValue = 0;
configs.add(config);
}
}
}
}
ASSERT(configs.size() > 0);
return configs;
}
......
......@@ -47,7 +47,7 @@ class Renderer9 : public RendererD3D
virtual EGLint initialize();
virtual bool resetDevice();
std::vector<ConfigDesc> generateConfigs() const override;
egl::ConfigSet generateConfigs() const override;
void startScene();
void endScene();
......
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