Hash :
4d3a0f60
Author :
Date :
2020-09-11T12:36:05
GN: Componentize D3D format tables. These tables are used by both the GL and D3D11 back-ends. Also moves them to renderer_utils to be in a shared place. Bug: angleproject:3943 Change-Id: I1f5d79842396a87e795547fa03c6855d6f9c5e9a Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2405805 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jonah Ryan-Davis <jonahr@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// d3d_format: Describes a D3D9 format. Used by the D3D9 and GL back-ends.
#include "libANGLE/renderer/d3d_format.h"
using namespace angle;
namespace rx
{
namespace d3d9
{
namespace
{
constexpr D3DFORMAT D3DFMT_INTZ = ((D3DFORMAT)(MAKEFOURCC('I', 'N', 'T', 'Z')));
constexpr D3DFORMAT D3DFMT_NULL = ((D3DFORMAT)(MAKEFOURCC('N', 'U', 'L', 'L')));
} // anonymous namespace
D3DFormat::D3DFormat()
: pixelBytes(0),
blockWidth(0),
blockHeight(0),
redBits(0),
greenBits(0),
blueBits(0),
alphaBits(0),
luminanceBits(0),
depthBits(0),
stencilBits(0),
formatID(angle::FormatID::NONE)
{}
D3DFormat::D3DFormat(GLuint bits,
GLuint blockWidth,
GLuint blockHeight,
GLuint redBits,
GLuint greenBits,
GLuint blueBits,
GLuint alphaBits,
GLuint lumBits,
GLuint depthBits,
GLuint stencilBits,
FormatID formatID)
: pixelBytes(bits / 8),
blockWidth(blockWidth),
blockHeight(blockHeight),
redBits(redBits),
greenBits(greenBits),
blueBits(blueBits),
alphaBits(alphaBits),
luminanceBits(lumBits),
depthBits(depthBits),
stencilBits(stencilBits),
formatID(formatID)
{}
const D3DFormat &GetD3DFormatInfo(D3DFORMAT format)
{
if (format == D3DFMT_NULL)
{
static const D3DFormat info(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FormatID::NONE);
return info;
}
if (format == D3DFMT_INTZ)
{
static const D3DFormat info(32, 1, 1, 0, 0, 0, 0, 0, 24, 8, FormatID::D24_UNORM_S8_UINT);
return info;
}
switch (format)
{
case D3DFMT_UNKNOWN:
{
static const D3DFormat info(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, FormatID::NONE);
return info;
}
case D3DFMT_L8:
{
static const D3DFormat info(8, 1, 1, 0, 0, 0, 0, 8, 0, 0, FormatID::L8_UNORM);
return info;
}
case D3DFMT_A8:
{
static const D3DFormat info(8, 1, 1, 0, 0, 0, 8, 0, 0, 0, FormatID::A8_UNORM);
return info;
}
case D3DFMT_A8L8:
{
static const D3DFormat info(16, 1, 1, 0, 0, 0, 8, 8, 0, 0, FormatID::L8A8_UNORM);
return info;
}
case D3DFMT_A4R4G4B4:
{
static const D3DFormat info(16, 1, 1, 4, 4, 4, 4, 0, 0, 0, FormatID::B4G4R4A4_UNORM);
return info;
}
case D3DFMT_A1R5G5B5:
{
static const D3DFormat info(16, 1, 1, 5, 5, 5, 1, 0, 0, 0, FormatID::B5G5R5A1_UNORM);
return info;
}
case D3DFMT_R5G6B5:
{
static const D3DFormat info(16, 1, 1, 5, 6, 5, 0, 0, 0, 0, FormatID::R5G6B5_UNORM);
return info;
}
case D3DFMT_X8R8G8B8:
{
static const D3DFormat info(32, 1, 1, 8, 8, 8, 0, 0, 0, 0, FormatID::B8G8R8X8_UNORM);
return info;
}
case D3DFMT_A8R8G8B8:
{
static const D3DFormat info(32, 1, 1, 8, 8, 8, 8, 0, 0, 0, FormatID::B8G8R8A8_UNORM);
return info;
}
case D3DFMT_R16F:
{
static const D3DFormat info(16, 1, 1, 16, 0, 0, 0, 0, 0, 0, FormatID::R16_FLOAT);
return info;
}
case D3DFMT_G16R16F:
{
static const D3DFormat info(32, 1, 1, 16, 16, 0, 0, 0, 0, 0, FormatID::R16G16_FLOAT);
return info;
}
case D3DFMT_A16B16G16R16F:
{
static const D3DFormat info(64, 1, 1, 16, 16, 16, 16, 0, 0, 0,
FormatID::R16G16B16A16_FLOAT);
return info;
}
case D3DFMT_R32F:
{
static const D3DFormat info(32, 1, 1, 32, 0, 0, 0, 0, 0, 0, FormatID::R32_FLOAT);
return info;
}
case D3DFMT_G32R32F:
{
static const D3DFormat info(64, 1, 1, 32, 32, 0, 0, 0, 0, 0, FormatID::R32G32_FLOAT);
return info;
}
case D3DFMT_A32B32G32R32F:
{
static const D3DFormat info(128, 1, 1, 32, 32, 32, 32, 0, 0, 0,
FormatID::R32G32B32A32_FLOAT);
return info;
}
case D3DFMT_D16:
{
static const D3DFormat info(16, 1, 1, 0, 0, 0, 0, 0, 16, 0, FormatID::D16_UNORM);
return info;
}
case D3DFMT_D24S8:
{
static const D3DFormat info(32, 1, 1, 0, 0, 0, 0, 0, 24, 8,
FormatID::D24_UNORM_S8_UINT);
return info;
}
case D3DFMT_D24X8:
{
static const D3DFormat info(32, 1, 1, 0, 0, 0, 0, 0, 24, 0, FormatID::D16_UNORM);
return info;
}
case D3DFMT_D32:
{
static const D3DFormat info(32, 1, 1, 0, 0, 0, 0, 0, 32, 0, FormatID::D32_UNORM);
return info;
}
case D3DFMT_DXT1:
{
static const D3DFormat info(64, 4, 4, 0, 0, 0, 0, 0, 0, 0,
FormatID::BC1_RGBA_UNORM_BLOCK);
return info;
}
case D3DFMT_DXT3:
{
static const D3DFormat info(128, 4, 4, 0, 0, 0, 0, 0, 0, 0,
FormatID::BC2_RGBA_UNORM_BLOCK);
return info;
}
case D3DFMT_DXT5:
{
static const D3DFormat info(128, 4, 4, 0, 0, 0, 0, 0, 0, 0,
FormatID::BC3_RGBA_UNORM_BLOCK);
return info;
}
default:
{
static const D3DFormat defaultInfo;
return defaultInfo;
}
}
}
} // namespace d3d9
} // namespace rx