Moves Config generation to Renderer.

TRAC #21819 Signed-off-by: Daniel Koch Author: Shannon Woods git-svn-id: https://angleproject.googlecode.com/svn/branches/dx11proto@1350 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent 6f50457c
...@@ -22,20 +22,12 @@ using namespace std; ...@@ -22,20 +22,12 @@ using namespace std;
namespace egl namespace egl
{ {
Config::Config(EGLenum displayFormat, EGLint displayWidth, EGLint displayHeight, EGLint minInterval, EGLint maxInterval, Config::Config(renderer::ConfigDesc desc, EGLint minInterval, EGLint maxInterval, EGLint texWidth, EGLint texHeight)
EGLenum renderTargetFormat, EGLenum depthStencilFormat, EGLint multiSample, EGLint texWidth, EGLint texHeight) : mRenderTargetFormat(desc.renderTargetFormat), mDepthStencilFormat(desc.depthStencilFormat), mMultiSample(desc.multiSample)
: mDisplayFormat(displayFormat), mDisplayWidth(displayWidth), mDisplayHeight(displayHeight), mRenderTargetFormat(renderTargetFormat), mDepthStencilFormat(depthStencilFormat),
mMultiSample(multiSample)
{
set(minInterval, maxInterval, renderTargetFormat, depthStencilFormat, multiSample, texWidth, texHeight);
}
void Config::set(EGLint minInterval, EGLint maxInterval, EGLenum renderTargetFormat, EGLenum depthStencilFormat,
EGLint multiSample, EGLint texWidth, EGLint texHeight)
{ {
mBindToTextureRGB = EGL_FALSE; mBindToTextureRGB = EGL_FALSE;
mBindToTextureRGBA = EGL_FALSE; mBindToTextureRGBA = EGL_FALSE;
switch (renderTargetFormat) switch (desc.renderTargetFormat)
{ {
case GL_RGB5_A1: case GL_RGB5_A1:
mBufferSize = 16; mBufferSize = 16;
...@@ -74,11 +66,11 @@ void Config::set(EGLint minInterval, EGLint maxInterval, EGLenum renderTargetFor ...@@ -74,11 +66,11 @@ void Config::set(EGLint minInterval, EGLint maxInterval, EGLenum renderTargetFor
mLuminanceSize = 0; mLuminanceSize = 0;
mAlphaMaskSize = 0; mAlphaMaskSize = 0;
mColorBufferType = EGL_RGB_BUFFER; mColorBufferType = EGL_RGB_BUFFER;
mConfigCaveat = (mDisplayFormat == renderTargetFormat) ? EGL_NONE : EGL_SLOW_CONFIG; mConfigCaveat = (desc.fastConfig) ? EGL_NONE : EGL_SLOW_CONFIG;
mConfigID = 0; mConfigID = 0;
mConformant = EGL_OPENGL_ES2_BIT; mConformant = EGL_OPENGL_ES2_BIT;
switch (depthStencilFormat) switch (desc.depthStencilFormat)
{ {
case GL_NONE: case GL_NONE:
mDepthSize = 0; mDepthSize = 0;
...@@ -115,8 +107,8 @@ void Config::set(EGLint minInterval, EGLint maxInterval, EGLenum renderTargetFor ...@@ -115,8 +107,8 @@ void Config::set(EGLint minInterval, EGLint maxInterval, EGLenum renderTargetFor
mNativeVisualID = 0; mNativeVisualID = 0;
mNativeVisualType = 0; mNativeVisualType = 0;
mRenderableType = EGL_OPENGL_ES2_BIT; mRenderableType = EGL_OPENGL_ES2_BIT;
mSampleBuffers = multiSample ? 1 : 0; mSampleBuffers = desc.multiSample ? 1 : 0;
mSamples = multiSample; mSamples = desc.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;
mTransparentRedValue = 0; mTransparentRedValue = 0;
...@@ -230,11 +222,9 @@ ConfigSet::ConfigSet() ...@@ -230,11 +222,9 @@ ConfigSet::ConfigSet()
{ {
} }
void ConfigSet::add(EGLenum displayFormat, EGLint displayWidth, EGLint displayHeight, EGLint minSwapInterval, EGLint maxSwapInterval, void ConfigSet::add(renderer::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight)
EGLenum renderTargetFormat, EGLenum depthStencilFormat,EGLint multiSample, EGLint texWidth, EGLint texHeight)
{ {
Config config(displayFormat, displayWidth, displayHeight, minSwapInterval, maxSwapInterval, renderTargetFormat, depthStencilFormat, Config config(desc, minSwapInterval, maxSwapInterval, texWidth, texHeight);
multiSample, texWidth, texHeight);
mSet.insert(config); mSet.insert(config);
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <set> #include <set>
#include "libGLESv2/renderer/Renderer.h"
#include "common/angleutils.h" #include "common/angleutils.h"
namespace egl namespace egl
...@@ -25,19 +26,13 @@ class Display; ...@@ -25,19 +26,13 @@ class Display;
class Config class Config
{ {
public: public:
Config(EGLenum displayFormat, EGLint displayWidth, EGLint displayHeight, EGLint minSwapInterval, EGLint maxSwapInterval, Config(renderer::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight);
EGLenum renderTargetFormat, EGLenum depthStencilFormat, EGLint multiSample, EGLint texWidth, EGLint texHeight);
void set(EGLint minSwapInterval, EGLint maxSwapInterval, EGLenum renderTargetFormat, EGLenum depthStencilFormat,
EGLint multiSample, EGLint texWidth, EGLint texHeight);
EGLConfig getHandle() const; EGLConfig getHandle() const;
const EGLenum mRenderTargetFormat; const GLenum mRenderTargetFormat;
const EGLenum mDepthStencilFormat; const GLenum mDepthStencilFormat;
const EGLint mMultiSample; const GLint mMultiSample;
const EGLint mDisplayWidth;
const EGLint mDisplayHeight;
const EGLenum mDisplayFormat;
EGLint mBufferSize; // Depth of the color buffer EGLint mBufferSize; // Depth of the color buffer
EGLint mRedSize; // Bits of Red in the color buffer EGLint mRedSize; // Bits of Red in the color buffer
...@@ -101,8 +96,7 @@ class ConfigSet ...@@ -101,8 +96,7 @@ class ConfigSet
public: public:
ConfigSet(); ConfigSet();
void add(EGLenum displayFormat, EGLint displayWidth, EGLint displayHeight, EGLint minSwapInterval, EGLint maxSwapInterval, void add(renderer::ConfigDesc desc, EGLint minSwapInterval, EGLint maxSwapInterval, EGLint texWidth, EGLint texHeight);
EGLenum renderTargetFormat, EGLenum depthStencilFormat, EGLint multiSample, EGLint texWidth, EGLint texHeight);
size_t size() const; size_t size() const;
bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig); bool getConfigs(EGLConfig *configs, const EGLint *attribList, EGLint configSize, EGLint *numConfig);
const egl::Config *get(EGLConfig configHandle); const egl::Config *get(EGLConfig configHandle);
......
...@@ -28,46 +28,6 @@ namespace ...@@ -28,46 +28,6 @@ namespace
DisplayMap displays; DisplayMap displays;
} }
// D3D9_REMOVE - Temporary duplication of this conversion function until remainder of d3d types are stripped
GLenum ConvertBackBufferFormat(D3DFORMAT format)
{
switch (format)
{
case D3DFMT_A4R4G4B4: return GL_RGBA4;
case D3DFMT_A8R8G8B8: return GL_RGBA8_OES;
case D3DFMT_A1R5G5B5: return GL_RGB5_A1;
case D3DFMT_R5G6B5: return GL_RGB565;
case D3DFMT_X8R8G8B8: return GL_RGB8_OES;
default:
UNREACHABLE();
}
return GL_RGBA4;
}
// D3D9_REMOVE - Temporary duplication of this conversion function until remainder of d3d types are stripped
GLenum ConvertDepthStencilFormat(D3DFORMAT format)
{
if (format == D3DFMT_INTZ)
{
return GL_DEPTH24_STENCIL8_OES;
}
switch (format)
{
case D3DFMT_D16:
case D3DFMT_D24X8:
return GL_DEPTH_COMPONENT16;
case D3DFMT_D24S8:
return GL_DEPTH24_STENCIL8_OES;
case D3DFMT_UNKNOWN:
return GL_NONE; // This case diverges from the one in utilities-- but this function gets removed imminently.
default:
UNREACHABLE();
}
return GL_DEPTH24_STENCIL8_OES;
}
egl::Display *Display::getDisplay(EGLNativeDisplayType displayId) egl::Display *Display::getDisplay(EGLNativeDisplayType displayId)
{ {
if (displays.find(displayId) != displays.end()) if (displays.find(displayId) != displays.end())
...@@ -149,82 +109,17 @@ bool Display::initialize() ...@@ -149,82 +109,17 @@ bool Display::initialize()
terminate(); terminate();
return error(status, false); return error(status, false);
} }
IDirect3D9 *d3d9 = mRenderer->getD3D(); // D3D9_REPLACE
UINT adapter = mRenderer->getAdapter(); // D3D9_REPLACE
D3DDEVTYPE deviceType = mRenderer->getDeviceType(); // D3D9_REPLACE
IDirect3DDevice9 *device = mRenderer->getDevice(); // D3D9_REPLACE
mMinSwapInterval = mRenderer->getMinSwapInterval(); mMinSwapInterval = mRenderer->getMinSwapInterval();
mMaxSwapInterval = mRenderer->getMaxSwapInterval(); mMaxSwapInterval = mRenderer->getMaxSwapInterval();
// START D3D9_REPLACE renderer::ConfigDesc *descList;
const D3DFORMAT renderTargetFormats[] = int numConfigs = mRenderer->generateConfigs(&descList);
{
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
};
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
};
D3DDISPLAYMODE currentDisplayMode;
d3d9->GetAdapterDisplayMode(adapter, &currentDisplayMode);
ConfigSet configSet; ConfigSet configSet;
for (int formatIndex = 0; formatIndex < sizeof(renderTargetFormats) / sizeof(D3DFORMAT); formatIndex++) for (int i = 0; i < numConfigs; ++i)
{ configSet.add(descList[i], mMinSwapInterval, mMaxSwapInterval,
D3DFORMAT renderTargetFormat = renderTargetFormats[formatIndex]; mRenderer->getMaxTextureWidth(), mRenderer->getMaxTextureHeight());
HRESULT result = d3d9->CheckDeviceFormat(adapter, deviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, renderTargetFormat);
if (SUCCEEDED(result))
{
for (int depthStencilIndex = 0; depthStencilIndex < sizeof(depthStencilFormats) / sizeof(D3DFORMAT); depthStencilIndex++)
{
D3DFORMAT depthStencilFormat = depthStencilFormats[depthStencilIndex];
HRESULT result = D3D_OK;
if(depthStencilFormat != D3DFMT_UNKNOWN)
{
result = d3d9->CheckDeviceFormat(adapter, deviceType, currentDisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, depthStencilFormat);
}
if (SUCCEEDED(result))
{
if(depthStencilFormat != D3DFMT_UNKNOWN)
{
result = d3d9->CheckDepthStencilMatch(adapter, deviceType, currentDisplayMode.Format, renderTargetFormat, depthStencilFormat);
}
if (SUCCEEDED(result))
{
// FIXME: enumerate multi-sampling
configSet.add(ConvertBackBufferFormat(currentDisplayMode.Format), currentDisplayMode.Width, currentDisplayMode.Height, mMinSwapInterval, mMaxSwapInterval,
ConvertBackBufferFormat(renderTargetFormat), ConvertDepthStencilFormat(depthStencilFormat), 0,
mRenderer->getMaxTextureWidth(), mRenderer->getMaxTextureHeight());
}
}
}
}
}
// END D3D9_REPLACE
// 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;
...@@ -237,6 +132,9 @@ bool Display::initialize() ...@@ -237,6 +132,9 @@ bool Display::initialize()
mConfigSet.mSet.insert(configuration); mConfigSet.mSet.insert(configuration);
} }
mRenderer->deleteConfigs(descList);
descList = NULL;
if (!isInitialized()) if (!isInitialized())
{ {
terminate(); terminate();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "common/debug.h" #include "common/debug.h"
#include "libGLESv2/utilities.h" #include "libGLESv2/utilities.h"
#include "libEGL/Config.h"
#include "libEGL/Display.h" #include "libEGL/Display.h"
// Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros // Can also be enabled by defining FORCE_REF_RAST in the project's predefined macros
...@@ -348,6 +349,64 @@ D3DPRESENT_PARAMETERS Renderer::getDefaultPresentParameters() ...@@ -348,6 +349,64 @@ D3DPRESENT_PARAMETERS Renderer::getDefaultPresentParameters()
return presentParameters; return presentParameters;
} }
int Renderer::generateConfigs(ConfigDesc **configDescList)
{
D3DDISPLAYMODE currentDisplayMode;
mD3d9->GetAdapterDisplayMode(mAdapter, &currentDisplayMode);
int numRenderFormats = sizeof(mRenderTargetFormats) / sizeof(mRenderTargetFormats[0]);
int numDepthFormats = sizeof(mDepthStencilFormats) / sizeof(mDepthStencilFormats[0]);
(*configDescList) = new ConfigDesc[numRenderFormats * numDepthFormats];
int numConfigs = 0;
for (int formatIndex = 0; formatIndex < numRenderFormats; formatIndex++)
{
D3DFORMAT renderTargetFormat = mRenderTargetFormats[formatIndex];
HRESULT result = mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_RENDERTARGET, D3DRTYPE_SURFACE, renderTargetFormat);
if (SUCCEEDED(result))
{
for (int depthStencilIndex = 0; depthStencilIndex < numDepthFormats; depthStencilIndex++)
{
D3DFORMAT depthStencilFormat = mDepthStencilFormats[depthStencilIndex];
HRESULT result = D3D_OK;
if(depthStencilFormat != D3DFMT_UNKNOWN)
{
result = mD3d9->CheckDeviceFormat(mAdapter, mDeviceType, currentDisplayMode.Format, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, depthStencilFormat);
}
if (SUCCEEDED(result))
{
if(depthStencilFormat != D3DFMT_UNKNOWN)
{
result = mD3d9->CheckDepthStencilMatch(mAdapter, mDeviceType, currentDisplayMode.Format, renderTargetFormat, depthStencilFormat);
}
if (SUCCEEDED(result))
{
ConfigDesc newConfig;
newConfig.renderTargetFormat = dx2es::ConvertBackBufferFormat(renderTargetFormat);
newConfig.depthStencilFormat = dx2es::ConvertDepthStencilFormat(depthStencilFormat);
newConfig.multiSample = 0; // FIXME: enumerate multi-sampling
newConfig.fastConfig = (currentDisplayMode.Format == renderTargetFormat);
(*configDescList)[numConfigs++] = newConfig;
}
}
}
}
}
return numConfigs;
}
void Renderer::deleteConfigs(ConfigDesc *configDescList)
{
delete [] (configDescList);
}
void Renderer::startScene() void Renderer::startScene()
{ {
if (!mSceneStarted) if (!mSceneStarted)
......
...@@ -48,6 +48,14 @@ class Display; ...@@ -48,6 +48,14 @@ class Display;
namespace renderer namespace renderer
{ {
struct ConfigDesc
{
GLenum renderTargetFormat;
GLenum depthStencilFormat;
GLint multiSample;
bool fastConfig;
};
class Renderer class Renderer
{ {
public: public:
...@@ -57,6 +65,9 @@ class Renderer ...@@ -57,6 +65,9 @@ class Renderer
virtual EGLint initialize(); virtual EGLint initialize();
virtual bool resetDevice(); virtual bool resetDevice();
virtual int generateConfigs(ConfigDesc **configDescList);
virtual void deleteConfigs(ConfigDesc *configDescList);
virtual void startScene(); virtual void startScene();
virtual void endScene(); virtual void endScene();
...@@ -92,9 +103,6 @@ class Renderer ...@@ -92,9 +103,6 @@ class Renderer
// Renderer capabilities // Renderer capabilities
virtual IDirect3DDevice9 *getDevice() {return mDevice;}; // D3D9_REPLACE virtual IDirect3DDevice9 *getDevice() {return mDevice;}; // D3D9_REPLACE
virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier() {return &mAdapterIdentifier;}; // D3D9_REPLACE virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier() {return &mAdapterIdentifier;}; // D3D9_REPLACE
virtual IDirect3D9 *getD3D() {return mD3d9;}; // D3D9_REMOVE
virtual UINT getAdapter() {return mAdapter;}; // 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 bool getDXT1TextureSupport(); virtual bool getDXT1TextureSupport();
......
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