Commit a5ac1e16 by Jamie Madill Committed by Commit Bot

D3D9: Use angle::Format when possible.

This will unify the way we call into PackPixels and also cleans u the code. It required adding a few D3D9-specific formats to the table. BUG=angleproject:1455 Change-Id: Ic8282f40f52cabdb2925e2bb305c26582284082d Reviewed-on: https://chromium-review.googlesource.com/365825 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarZhenyao Mo <zmo@chromium.org>
parent a5b1561e
......@@ -18,6 +18,7 @@ enum class Format::ID
B5G5R5A1_UNORM,
B5G6R5_UNORM,
B8G8R8A8_UNORM,
B8G8R8X8_UNORM,
BC1_UNORM,
BC2_UNORM,
BC3_UNORM,
......@@ -25,6 +26,9 @@ enum class Format::ID
D24_UNORM_S8_UINT,
D32_FLOAT,
D32_FLOAT_S8X24_UINT,
D32_UNORM,
L8A8_LUMA,
L8_LUMA,
R10G10B10A2_UINT,
R10G10B10A2_UNORM,
R11G11B10_FLOAT,
......@@ -52,6 +56,7 @@ enum class Format::ID
R32_FLOAT,
R32_SINT,
R32_UINT,
R5G6B5_UNORM,
R8G8B8A8_SINT,
R8G8B8A8_SNORM,
R8G8B8A8_UINT,
......
......@@ -68,6 +68,15 @@ const Format &Format::Get(ID id)
ReadColor<B8G8R8A8, GLfloat>);
return info;
}
case ID::B8G8R8X8_UNORM:
{
static const Format info(ID::B8G8R8X8_UNORM,
GL_BGRA8_EXT,
GL_BGRA8_EXT,
GenerateMip<B8G8R8X8>,
ReadColor<B8G8R8X8, GLfloat>);
return info;
}
case ID::BC1_UNORM:
{
static const Format info(ID::BC1_UNORM,
......@@ -131,6 +140,33 @@ const Format &Format::Get(ID id)
nullptr);
return info;
}
case ID::D32_UNORM:
{
static const Format info(ID::D32_UNORM,
GL_DEPTH_COMPONENT32_OES,
GL_DEPTH_COMPONENT32_OES,
nullptr,
nullptr);
return info;
}
case ID::L8A8_LUMA:
{
static const Format info(ID::L8A8_LUMA,
GL_LUMINANCE8_ALPHA8_EXT,
GL_LUMINANCE8_ALPHA8_EXT,
GenerateMip<L8A8>,
ReadColor<L8A8, GLfloat>);
return info;
}
case ID::L8_LUMA:
{
static const Format info(ID::L8_LUMA,
GL_LUMINANCE8_EXT,
GL_LUMINANCE8_EXT,
GenerateMip<L8>,
ReadColor<L8, GLfloat>);
return info;
}
case ID::NONE:
{
static const Format info(ID::NONE,
......@@ -383,6 +419,15 @@ const Format &Format::Get(ID id)
ReadColor<R32, GLuint>);
return info;
}
case ID::R5G6B5_UNORM:
{
static const Format info(ID::R5G6B5_UNORM,
GL_RGB565,
GL_RGB565,
GenerateMip<R5G6B5>,
ReadColor<R5G6B5, GLfloat>);
return info;
}
case ID::R8G8B8A8_SINT:
{
static const Format info(ID::R8G8B8A8_SINT,
......
......@@ -77,6 +77,25 @@
"bits": { "depth": 32 },
"glInternalFormat": "GL_DEPTH_COMPONENT32F"
},
"D32_UNORM": {
"channels": "d",
"componentType": "unorm",
"bits": { "depth": 32 },
"glInternalFormat": "GL_DEPTH_COMPONENT32_OES"
},
"L8_LUMA": {
"channels": "l",
"componentType": "unorm",
"bits": { "luma": 8 },
"glInternalFormat": "GL_LUMINANCE8_EXT"
},
"L8A8_LUMA": {
"channels": "la",
"componentType": "unorm",
"bits": { "luma": 8, "alpha": 8 },
"glInternalFormat": "GL_LUMINANCE8_ALPHA8_EXT",
"channelStruct": "L8A8"
},
"R11G11B10_FLOAT": {
"channels": "rgb",
"componentType": "float",
......@@ -255,6 +274,12 @@
"fboImplementationInternalFormat": "GL_RGB5_A1",
"channelStruct": "A1R5G5B5"
},
"R5G6B5_UNORM": {
"channels": "rgb",
"componentType": "unorm",
"bits": { "red": 5, "green": 6, "blue": 5 },
"glInternalFormat": "GL_RGB565"
},
"R8G8B8A8_SINT": {
"channels": "rgba",
"componentType": "int",
......@@ -273,6 +298,13 @@
"bits": { "red": 8, "green": 8, "blue": 8, "alpha": 8 },
"glInternalFormat": "GL_RGBA8_SNORM"
},
"B8G8R8X8_UNORM": {
"channels": "bgr",
"componentType": "unorm",
"bits": { "red": 8, "green": 8, "blue": 8 },
"glInternalFormat": "GL_BGRA8_EXT",
"channelStruct": "B8G8R8X8"
},
"R9G9B9E5_SHAREDEXP": {
"channels": "rgb",
"componentType": "float",
......
......@@ -192,9 +192,10 @@ gl::Error Framebuffer9::readPixelsImpl(const gl::Rectangle &area,
int inputPitch = lock.Pitch;
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
const gl::InternalFormat &sourceFormatInfo = gl::GetInternalFormatInfo(d3dFormatInfo.internalFormat);
const gl::InternalFormat &sourceFormatInfo =
gl::GetInternalFormatInfo(d3dFormatInfo.info->glInternalFormat);
gl::FormatType formatType(format, type);
ColorReadFunction colorReadFunction = d3dFormatInfo.colorReadFunction;
ColorReadFunction colorReadFunction = d3dFormatInfo.info->colorReadFunction;
// TODO(jmadill): Maybe we can avoid a copy of pack parameters here?
PackPixelsParams packParams;
......@@ -407,7 +408,7 @@ GLenum Framebuffer9::getRenderTargetImplementationFormat(RenderTargetD3D *render
{
RenderTarget9 *renderTarget9 = GetAs<RenderTarget9>(renderTarget);
const d3d9::D3DFormat &d3dFormatInfo = d3d9::GetD3DFormatInfo(renderTarget9->getD3DFormat());
return d3dFormatInfo.internalFormat;
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.mipGenerationFunction != NULL);
ASSERT(d3dFormatInfo.info->mipGenerationFunction != NULL);
D3DLOCKED_RECT sourceLocked = {0};
result = sourceSurface->LockRect(&sourceLocked, NULL, D3DLOCK_READONLY);
......@@ -85,8 +85,8 @@ gl::Error Image9::generateMip(IDirect3DSurface9 *destSurface, IDirect3DSurface9
ASSERT(sourceData && destData);
d3dFormatInfo.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();
......
......@@ -15,6 +15,7 @@
#include "common/platform.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/Format.h"
#include "libANGLE/renderer/renderer_utils.h"
#include "libANGLE/renderer/d3d/formatutilsD3D.h"
......@@ -43,10 +44,7 @@ struct D3DFormat
GLuint depthBits;
GLuint stencilBits;
GLenum internalFormat;
MipGenerationFunction mipGenerationFunction;
ColorReadFunction colorReadFunction;
const angle::Format *info;
FastCopyFunctionMap fastCopyFunctions;
};
......
......@@ -306,7 +306,7 @@ GLsizei GetSamplesCount(D3DMULTISAMPLE_TYPE type)
bool IsFormatChannelEquivalent(D3DFORMAT d3dformat, GLenum format)
{
GLenum internalFormat = d3d9::GetD3DFormatInfo(d3dformat).internalFormat;
GLenum internalFormat = d3d9::GetD3DFormatInfo(d3dformat).info->glInternalFormat;
GLenum convertedFormat = gl::GetInternalFormatInfo(internalFormat).format;
return convertedFormat == format;
}
......
......@@ -93,6 +93,8 @@ def get_channel_struct(angle_format):
struct_name += 'B{}'.format(bits['blue'])
if channel == 'a':
struct_name += 'A{}'.format(bits['alpha'])
if channel == 'l':
struct_name += 'L{}'.format(bits['luma'])
if angle_format['componentType'] == 'float':
struct_name += 'F'
if angle_format['componentType'] == 'int' or angle_format['componentType'] == 'snorm':
......
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