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, ...@@ -205,7 +205,7 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area,
packParams.outputPitch = static_cast<GLuint>(outputPitch); packParams.outputPitch = static_cast<GLuint>(outputPitch);
packParams.pack = pack; packParams.pack = pack;
PackPixels(packParams, *d3dFormatInfo.info, inputPitch, source, pixels); PackPixels(packParams, d3dFormatInfo.info(), inputPitch, source, pixels);
systemSurface->UnlockRect(); systemSurface->UnlockRect();
SafeRelease(systemSurface); SafeRelease(systemSurface);
...@@ -404,7 +404,7 @@ GLenum Framebuffer9::getRenderTargetImplementationFormat(RenderTargetD3D *render ...@@ -404,7 +404,7 @@ GLenum Framebuffer9::getRenderTargetImplementationFormat(RenderTargetD3D *render
{ {
RenderTarget9 *renderTarget9 = GetAs<RenderTarget9>(renderTarget); RenderTarget9 *renderTarget9 = GetAs<RenderTarget9>(renderTarget);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(renderTarget9->getD3DFormat()); const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(renderTarget9->getD3DFormat());
return d3dFormatInfo.info->glInternalFormat; return d3dFormatInfo.info().glInternalFormat;
} }
} // namespace rx } // namespace rx
...@@ -61,7 +61,7 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 ...@@ -61,7 +61,7 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9
ASSERT(sourceDesc.Height == 1 || sourceDesc.Height / 2 == destDesc.Height); ASSERT(sourceDesc.Height == 1 || sourceDesc.Height / 2 == destDesc.Height);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(sourceDesc.Format); const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(sourceDesc.Format);
ASSERT(d3dFormatInfo.info->mipGenerationFunction != NULL); ASSERT(d3dFormatInfo.info().mipGenerationFunction != NULL);
D3DLOCKED_RECT sourceLocked = {0}; D3DLOCKED_RECT sourceLocked = {0};
result = sourceSurface->LockRect(&sourceLocked, NULL, D3DLOCK_READONLY); result = sourceSurface->LockRect(&sourceLocked, NULL, D3DLOCK_READONLY);
...@@ -85,8 +85,9 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9 ...@@ -85,8 +85,9 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9
ASSERT(sourceData && destData); ASSERT(sourceData && destData);
d3dFormatInfo.info->mipGenerationFunction(sourceDesc.Width, sourceDesc.Height, 1, sourceData, d3dFormatInfo.info().mipGenerationFunction(sourceDesc.Width, sourceDesc.Height, 1, sourceData,
sourceLocked.Pitch, 0, destData, destLocked.Pitch, 0); sourceLocked.Pitch, 0, destData, destLocked.Pitch,
0);
destSurface->UnlockRect(); destSurface->UnlockRect();
sourceSurface->UnlockRect(); sourceSurface->UnlockRect();
......
...@@ -732,8 +732,8 @@ egl::Error Renderer9::getD3DTextureInfo(IUnknown *d3dTexture, ...@@ -732,8 +732,8 @@ egl::Error Renderer9::getD3DTextureInfo(IUnknown *d3dTexture,
if (fboFormat) if (fboFormat)
{ {
const auto &d3dFormatInfo = d3d9::GetD3DFormatInfo(desc.Format); const auto &d3dFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
ASSERT(d3dFormatInfo.info != nullptr); ASSERT(d3dFormatInfo.info().id != angle::Format::ID::NONE);
*fboFormat = d3dFormatInfo.info->fboImplementationInternalFormat; *fboFormat = d3dFormatInfo.info().fboImplementationInternalFormat;
} }
return egl::Error(EGL_SUCCESS); return egl::Error(EGL_SUCCESS);
......
...@@ -29,7 +29,20 @@ namespace d3d9 ...@@ -29,7 +29,20 @@ namespace d3d9
struct D3DFormat 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 pixelBytes;
GLuint blockWidth; GLuint blockWidth;
...@@ -44,7 +57,7 @@ struct D3DFormat ...@@ -44,7 +57,7 @@ struct D3DFormat
GLuint depthBits; GLuint depthBits;
GLuint stencilBits; GLuint stencilBits;
const angle::Format *info; angle::Format::ID formatID;
}; };
const D3DFormat &GetD3DFormatInfo(D3DFORMAT format); const D3DFormat &GetD3DFormatInfo(D3DFORMAT format);
......
...@@ -307,7 +307,7 @@ GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type) ...@@ -307,7 +307,7 @@ GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type)
bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format) 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; GLenum convertedFormat = gl::GetInternalFormatInfo(internalFormat).format;
return convertedFormat == 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