Commit 032e3702 by Jamie Madill Committed by Commit Bot

D3D9: Make GetD3DFormatInfo constexpr.

This removes another static global map initializer. BUG=angleproject:1389 BUG=angleproject:1459 Change-Id: I302f349ea4e95d079077866a07b0d57758c40892 Reviewed-on: https://chromium-review.googlesource.com/405488 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 9cec39f6
......@@ -205,7 +205,7 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area,
packParams.outputPitch = static_cast<GLuint>(outputPitch);
packParams.pack = pack;
PackPixels(packParams, *d3dFormatInfo.info, inputPitch, source, pixels);
PackPixels(packParams, d3dFormatInfo.info(), inputPitch, source, pixels);
systemSurface->UnlockRect();
SafeRelease(systemSurface);
......@@ -404,7 +404,7 @@ GLenum Framebuffer9::getRenderTargetImplementationFormat(RenderTargetD3D *render
{
RenderTarget9 *renderTarget9 = GetAs<RenderTarget9>(renderTarget);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(renderTarget9->getD3DFormat());
return d3dFormatInfo.info->glInternalFormat;
return d3dFormatInfo.info().glInternalFormat;
}
} // namespace rx
......@@ -61,7 +61,7 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9
ASSERT(sourceDesc.Height == 1 || sourceDesc.Height / 2 == destDesc.Height);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(sourceDesc.Format);
ASSERT(d3dFormatInfo.info->mipGenerationFunction != NULL);
ASSERT(d3dFormatInfo.info().mipGenerationFunction != NULL);
D3DLOCKED_RECT sourceLocked = {0};
result = sourceSurface->LockRect(&sourceLocked, NULL, D3DLOCK_READONLY);
......@@ -85,8 +85,9 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9
ASSERT(sourceData && destData);
d3dFormatInfo.info->mipGenerationFunction(sourceDesc.Width, sourceDesc.Height, 1, sourceData,
sourceLocked.Pitch, 0, destData, destLocked.Pitch, 0);
d3dFormatInfo.info().mipGenerationFunction(sourceDesc.Width, sourceDesc.Height, 1, sourceData,
sourceLocked.Pitch, 0, destData, destLocked.Pitch,
0);
destSurface->UnlockRect();
sourceSurface->UnlockRect();
......
......@@ -732,8 +732,8 @@ egl::Error Renderer9::getD3DTextureInfo(IUnknown *d3dTexture,
if (fboFormat)
{
const auto &d3dFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
ASSERT(d3dFormatInfo.info != nullptr);
*fboFormat = d3dFormatInfo.info->fboImplementationInternalFormat;
ASSERT(d3dFormatInfo.info().id != angle::Format::ID::NONE);
*fboFormat = d3dFormatInfo.info().fboImplementationInternalFormat;
}
return egl::Error(EGL_SUCCESS);
......
......@@ -29,7 +29,20 @@ namespace d3d9
struct D3DFormat
{
D3DFormat();
constexpr D3DFormat();
constexpr D3DFormat(GLuint pixelBytes,
GLuint blockWidth,
GLuint blockHeight,
GLuint redBits,
GLuint greenBits,
GLuint blueBits,
GLuint alphaBits,
GLuint luminanceBits,
GLuint depthBits,
GLuint stencilBits,
angle::Format::ID formatID);
const angle::Format &info() const { return angle::Format::Get(formatID); }
GLuint pixelBytes;
GLuint blockWidth;
......@@ -44,7 +57,7 @@ struct D3DFormat
GLuint depthBits;
GLuint stencilBits;
const angle::Format *info;
angle::Format::ID formatID;
};
const D3DFormat &GetD3DFormatInfo(D3DFORMAT format);
......
......@@ -307,7 +307,7 @@ GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type)
bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format)
{
GLenum internalFormat = d3d9::GetD3DFormatInfo(d3dformat).info->glInternalFormat;
GLenum internalFormat = d3d9::GetD3DFormatInfo(d3dformat).info().glInternalFormat;
GLenum convertedFormat = gl::GetInternalFormatInfo(internalFormat).format;
return convertedFormat == format;
}
......
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