Commit 0ab152ab by Austin Kinross Committed by Geoff Lang

Combine D3D11 FL10_0+ and FL9_3 LoadFunctionMaps

BUG=angleproject:1002 A 'LoadFunction' is used to load data of a given <GL format, GL type> pair into a specific DXGI_FORMAT. Before this change, BuildD3D11LoadFunctionMap mapped <GL format, GL type> pairs to LoadFunctions. This meant each <GL format, GL type> pair could only loaded using one LoadFunction, and therefore could only be loaded into one specific DXGI_FORMAT. We now want to map <GL format, GL type, DXGI_FORMAT> triples to LoadFunctions. This allows us to use different DXGI_FORMATS for each <GL format, GL type> pair, depending on the capabilities of the underlying D3D11 device. Change-Id: I3b5e24c4bf98f18360ddd45b2022a90b5000f866 Reviewed-on: https://chromium-review.googlesource.com/270561Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarAustin Kinross <aukinros@microsoft.com>
parent 9ce754eb
...@@ -535,12 +535,15 @@ static InternalFormatInitializerMap BuildInternalFormatInitializerMap() ...@@ -535,12 +535,15 @@ static InternalFormatInitializerMap BuildInternalFormatInitializerMap()
return map; return map;
} }
// ES3 image loading functions vary based on the internal format and data type given, // ES3 image loading functions vary based on:
// this map type determines the loading function from the internal format and type supplied // - the GL internal format (supplied to glTex*Image*D)
// to glTex*Image*D and the destination DXGI_FORMAT. Source formats and types are taken from // - the GL data type given (supplied to glTex*Image*D)
// Tables 3.2 and 3.3 of the ES 3 spec. // - the target DXGI_FORMAT that the image will be loaded into (which is chosen based on the D3D device's capabilities)
typedef std::pair<GLenum, LoadImageFunction> TypeLoadFunctionPair; // This map type determines which loading function to use, based on these three parameters.
typedef std::map<GLenum, std::vector<TypeLoadFunctionPair> > D3D11LoadFunctionMap; // Source formats and types are taken from Tables 3.2 and 3.3 of the ES 3 spec.
typedef std::pair<DXGI_FORMAT, LoadImageFunction> DxgiFormatLoadFunctionPair;
typedef std::pair<GLenum, DxgiFormatLoadFunctionPair> GLTypeDXGIFunctionPair;
typedef std::map<GLenum, std::vector<GLTypeDXGIFunctionPair> > D3D11LoadFunctionMap;
static void UnimplementedLoadFunction(size_t width, size_t height, size_t depth, static void UnimplementedLoadFunction(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch, const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
...@@ -558,184 +561,173 @@ static void UnreachableLoadFunction(size_t width, size_t height, size_t depth, ...@@ -558,184 +561,173 @@ static void UnreachableLoadFunction(size_t width, size_t height, size_t depth,
// A helper function to insert data into the D3D11LoadFunctionMap with fewer characters. // A helper function to insert data into the D3D11LoadFunctionMap with fewer characters.
static inline void InsertLoadFunction(D3D11LoadFunctionMap *map, GLenum internalFormat, GLenum type, static inline void InsertLoadFunction(D3D11LoadFunctionMap *map, GLenum internalFormat, GLenum type,
LoadImageFunction loadFunc) DXGI_FORMAT dxgiFormat, LoadImageFunction loadFunc)
{ {
(*map)[internalFormat].push_back(TypeLoadFunctionPair(type, loadFunc)); (*map)[internalFormat].push_back(GLTypeDXGIFunctionPair(type, DxgiFormatLoadFunctionPair(dxgiFormat, loadFunc)));
} }
D3D11LoadFunctionMap BuildD3D11_FL9_3_LoadFunctionMap() D3D11LoadFunctionMap BuildD3D11LoadFunctionMap()
{ {
D3D11LoadFunctionMap map; D3D11LoadFunctionMap map;
// From GL_EXT_texture_storage. Also used by GL_ALPHA8 // | Internal format | Type | Target DXGI Format | Load function |
// On feature level 9_3, A8_UNORM doesn't support mipmaps, so we must use RGBA8 instead InsertLoadFunction(&map, GL_RGBA8, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8B8A8_UNORM, LoadToNative<GLubyte, 4> );
InsertLoadFunction(&map, GL_ALPHA8_EXT, GL_UNSIGNED_BYTE, LoadA8ToRGBA8); InsertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8B8A8_UNORM, LoadToNative<GLubyte, 4> );
InsertLoadFunction(&map, GL_RGBA4, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8B8A8_UNORM, LoadToNative<GLubyte, 4> );
return map; InsertLoadFunction(&map, GL_SRGB8_ALPHA8, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, LoadToNative<GLubyte, 4> );
} InsertLoadFunction(&map, GL_RGBA8_SNORM, GL_BYTE, DXGI_FORMAT_R8G8B8A8_SNORM, LoadToNative<GLbyte, 4> );
InsertLoadFunction(&map, GL_RGBA4, GL_UNSIGNED_SHORT_4_4_4_4, DXGI_FORMAT_R8G8B8A8_UNORM, LoadRGBA4ToRGBA8 );
D3D11LoadFunctionMap BuildD3D11_FL10_0Plus_LoadFunctionMap() InsertLoadFunction(&map, GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV, DXGI_FORMAT_R10G10B10A2_UNORM, LoadToNative<GLuint, 1> );
{ InsertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_SHORT_5_5_5_1, DXGI_FORMAT_R8G8B8A8_UNORM, LoadRGB5A1ToRGBA8 );
D3D11LoadFunctionMap map; InsertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_INT_2_10_10_10_REV, DXGI_FORMAT_R8G8B8A8_UNORM, LoadRGB10A2ToRGBA8 );
InsertLoadFunction(&map, GL_RGBA16F, GL_HALF_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadToNative<GLhalf, 4> );
// From GL_EXT_texture_storage. Also used by GL_ALPHA8 InsertLoadFunction(&map, GL_RGBA16F, GL_HALF_FLOAT_OES, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadToNative<GLhalf, 4> );
InsertLoadFunction(&map, GL_ALPHA8_EXT, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 1>); InsertLoadFunction(&map, GL_RGBA32F, GL_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, LoadToNative<GLfloat, 4> );
InsertLoadFunction(&map, GL_RGBA16F, GL_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, Load32FTo16F<4> );
return map; InsertLoadFunction(&map, GL_RGBA8UI, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8B8A8_UINT, LoadToNative<GLubyte, 4> );
} InsertLoadFunction(&map, GL_RGBA8I, GL_BYTE, DXGI_FORMAT_R8G8B8A8_SINT, LoadToNative<GLbyte, 4> );
InsertLoadFunction(&map, GL_RGBA16UI, GL_UNSIGNED_SHORT, DXGI_FORMAT_R16G16B16A16_UINT, LoadToNative<GLushort, 4> );
D3D11LoadFunctionMap BuildBaseD3D11LoadFunctionMap() InsertLoadFunction(&map, GL_RGBA16I, GL_SHORT, DXGI_FORMAT_R16G16B16A16_SINT, LoadToNative<GLshort, 4> );
{ InsertLoadFunction(&map, GL_RGBA32UI, GL_UNSIGNED_INT, DXGI_FORMAT_R32G32B32A32_UINT, LoadToNative<GLuint, 4> );
D3D11LoadFunctionMap map; InsertLoadFunction(&map, GL_RGBA32I, GL_INT, DXGI_FORMAT_R32G32B32A32_SINT, LoadToNative<GLint, 4> );
InsertLoadFunction(&map, GL_RGB10_A2UI, GL_UNSIGNED_INT_2_10_10_10_REV, DXGI_FORMAT_R10G10B10A2_UINT, LoadToNative<GLuint, 1> );
// | Internal format | Type | Load function | InsertLoadFunction(&map, GL_RGB8, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8B8A8_UNORM, LoadToNative3To4<GLubyte, 0xFF> );
InsertLoadFunction(&map, GL_RGBA8, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> ); InsertLoadFunction(&map, GL_RGB565, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8B8A8_UNORM, LoadToNative3To4<GLubyte, 0xFF> );
InsertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> ); InsertLoadFunction(&map, GL_SRGB8, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, LoadToNative3To4<GLubyte, 0xFF> );
InsertLoadFunction(&map, GL_RGBA4, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> ); InsertLoadFunction(&map, GL_RGB8_SNORM, GL_BYTE, DXGI_FORMAT_R8G8B8A8_SNORM, LoadToNative3To4<GLbyte, 0x7F> );
InsertLoadFunction(&map, GL_SRGB8_ALPHA8, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> ); InsertLoadFunction(&map, GL_RGB565, GL_UNSIGNED_SHORT_5_6_5, DXGI_FORMAT_R8G8B8A8_UNORM, LoadR5G6B5ToRGBA8 );
InsertLoadFunction(&map, GL_RGBA8_SNORM, GL_BYTE, LoadToNative<GLbyte, 4> ); InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_UNSIGNED_INT_10F_11F_11F_REV, DXGI_FORMAT_R11G11B10_FLOAT, LoadToNative<GLuint, 1> );
InsertLoadFunction(&map, GL_RGBA4, GL_UNSIGNED_SHORT_4_4_4_4, LoadRGBA4ToRGBA8 ); InsertLoadFunction(&map, GL_RGB9_E5, GL_UNSIGNED_INT_5_9_9_9_REV, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, LoadToNative<GLuint, 1> );
InsertLoadFunction(&map, GL_RGB10_A2, GL_UNSIGNED_INT_2_10_10_10_REV, LoadToNative<GLuint, 1> ); InsertLoadFunction(&map, GL_RGB16F, GL_HALF_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadToNative3To4<GLhalf, gl::Float16One>);
InsertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_SHORT_5_5_5_1, LoadRGB5A1ToRGBA8 ); InsertLoadFunction(&map, GL_RGB16F, GL_HALF_FLOAT_OES, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadToNative3To4<GLhalf, gl::Float16One>);
InsertLoadFunction(&map, GL_RGB5_A1, GL_UNSIGNED_INT_2_10_10_10_REV, LoadRGB10A2ToRGBA8 ); InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_HALF_FLOAT, DXGI_FORMAT_R11G11B10_FLOAT, LoadRGB16FToRG11B10F );
InsertLoadFunction(&map, GL_RGBA16F, GL_HALF_FLOAT, LoadToNative<GLhalf, 4> ); InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_HALF_FLOAT_OES, DXGI_FORMAT_R11G11B10_FLOAT, LoadRGB16FToRG11B10F );
InsertLoadFunction(&map, GL_RGBA16F, GL_HALF_FLOAT_OES, LoadToNative<GLhalf, 4> ); InsertLoadFunction(&map, GL_RGB9_E5, GL_HALF_FLOAT, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, LoadRGB16FToRGB9E5 );
InsertLoadFunction(&map, GL_RGBA32F, GL_FLOAT, LoadToNative<GLfloat, 4> ); InsertLoadFunction(&map, GL_RGB9_E5, GL_HALF_FLOAT_OES, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, LoadRGB16FToRGB9E5 );
InsertLoadFunction(&map, GL_RGBA16F, GL_FLOAT, Load32FTo16F<4> ); InsertLoadFunction(&map, GL_RGB32F, GL_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, LoadToNative3To4<GLfloat, gl::Float32One>);
InsertLoadFunction(&map, GL_RGBA8UI, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> ); InsertLoadFunction(&map, GL_RGB16F, GL_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadRGB32FToRGBA16F );
InsertLoadFunction(&map, GL_RGBA8I, GL_BYTE, LoadToNative<GLbyte, 4> ); InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_FLOAT, DXGI_FORMAT_R11G11B10_FLOAT, LoadRGB32FToRG11B10F );
InsertLoadFunction(&map, GL_RGBA16UI, GL_UNSIGNED_SHORT, LoadToNative<GLushort, 4> ); InsertLoadFunction(&map, GL_RGB9_E5, GL_FLOAT, DXGI_FORMAT_R9G9B9E5_SHAREDEXP, LoadRGB32FToRGB9E5 );
InsertLoadFunction(&map, GL_RGBA16I, GL_SHORT, LoadToNative<GLshort, 4> ); InsertLoadFunction(&map, GL_RGB8UI, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8B8A8_UINT, LoadToNative3To4<GLubyte, 0x01> );
InsertLoadFunction(&map, GL_RGBA32UI, GL_UNSIGNED_INT, LoadToNative<GLuint, 4> ); InsertLoadFunction(&map, GL_RGB8I, GL_BYTE, DXGI_FORMAT_R8G8B8A8_SINT, LoadToNative3To4<GLbyte, 0x01> );
InsertLoadFunction(&map, GL_RGBA32I, GL_INT, LoadToNative<GLint, 4> ); InsertLoadFunction(&map, GL_RGB16UI, GL_UNSIGNED_SHORT, DXGI_FORMAT_R16G16B16A16_UINT, LoadToNative3To4<GLushort, 0x0001> );
InsertLoadFunction(&map, GL_RGB10_A2UI, GL_UNSIGNED_INT_2_10_10_10_REV, LoadToNative<GLuint, 1> ); InsertLoadFunction(&map, GL_RGB16I, GL_SHORT, DXGI_FORMAT_R16G16B16A16_SINT, LoadToNative3To4<GLshort, 0x0001> );
InsertLoadFunction(&map, GL_RGB8, GL_UNSIGNED_BYTE, LoadToNative3To4<GLubyte, 0xFF> ); InsertLoadFunction(&map, GL_RGB32UI, GL_UNSIGNED_INT, DXGI_FORMAT_R32G32B32A32_UINT, LoadToNative3To4<GLuint, 0x00000001> );
InsertLoadFunction(&map, GL_RGB565, GL_UNSIGNED_BYTE, LoadToNative3To4<GLubyte, 0xFF> ); InsertLoadFunction(&map, GL_RGB32I, GL_INT, DXGI_FORMAT_R32G32B32A32_SINT, LoadToNative3To4<GLint, 0x00000001> );
InsertLoadFunction(&map, GL_SRGB8, GL_UNSIGNED_BYTE, LoadToNative3To4<GLubyte, 0xFF> ); InsertLoadFunction(&map, GL_RG8, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8_UNORM, LoadToNative<GLubyte, 2> );
InsertLoadFunction(&map, GL_RGB8_SNORM, GL_BYTE, LoadToNative3To4<GLbyte, 0x7F> ); InsertLoadFunction(&map, GL_RG8_SNORM, GL_BYTE, DXGI_FORMAT_R8G8_SNORM, LoadToNative<GLbyte, 2> );
InsertLoadFunction(&map, GL_RGB565, GL_UNSIGNED_SHORT_5_6_5, LoadR5G6B5ToRGBA8 ); InsertLoadFunction(&map, GL_RG16F, GL_HALF_FLOAT, DXGI_FORMAT_R16G16_FLOAT, LoadToNative<GLhalf, 2> );
InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_UNSIGNED_INT_10F_11F_11F_REV, LoadToNative<GLuint, 1> ); InsertLoadFunction(&map, GL_RG16F, GL_HALF_FLOAT_OES, DXGI_FORMAT_R16G16_FLOAT, LoadToNative<GLhalf, 2> );
InsertLoadFunction(&map, GL_RGB9_E5, GL_UNSIGNED_INT_5_9_9_9_REV, LoadToNative<GLuint, 1> ); InsertLoadFunction(&map, GL_RG32F, GL_FLOAT, DXGI_FORMAT_R32G32_FLOAT, LoadToNative<GLfloat, 2> );
InsertLoadFunction(&map, GL_RGB16F, GL_HALF_FLOAT, LoadToNative3To4<GLhalf, gl::Float16One>); InsertLoadFunction(&map, GL_RG16F, GL_FLOAT, DXGI_FORMAT_R16G16_FLOAT, Load32FTo16F<2> );
InsertLoadFunction(&map, GL_RGB16F, GL_HALF_FLOAT_OES, LoadToNative3To4<GLhalf, gl::Float16One>); InsertLoadFunction(&map, GL_RG8UI, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8_UINT, LoadToNative<GLubyte, 2> );
InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_HALF_FLOAT, LoadRGB16FToRG11B10F ); InsertLoadFunction(&map, GL_RG8I, GL_BYTE, DXGI_FORMAT_R8G8_SINT, LoadToNative<GLbyte, 2> );
InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_HALF_FLOAT_OES, LoadRGB16FToRG11B10F ); InsertLoadFunction(&map, GL_RG16UI, GL_UNSIGNED_SHORT, DXGI_FORMAT_R16G16_UINT, LoadToNative<GLushort, 2> );
InsertLoadFunction(&map, GL_RGB9_E5, GL_HALF_FLOAT, LoadRGB16FToRGB9E5 ); InsertLoadFunction(&map, GL_RG16I, GL_SHORT, DXGI_FORMAT_R16G16_SINT, LoadToNative<GLshort, 2> );
InsertLoadFunction(&map, GL_RGB9_E5, GL_HALF_FLOAT_OES, LoadRGB16FToRGB9E5 ); InsertLoadFunction(&map, GL_RG32UI, GL_UNSIGNED_INT, DXGI_FORMAT_R32G32_UINT, LoadToNative<GLuint, 2> );
InsertLoadFunction(&map, GL_RGB32F, GL_FLOAT, LoadToNative3To4<GLfloat, gl::Float32One>); InsertLoadFunction(&map, GL_RG32I, GL_INT, DXGI_FORMAT_R32G32_SINT, LoadToNative<GLint, 2> );
InsertLoadFunction(&map, GL_RGB16F, GL_FLOAT, LoadRGB32FToRGBA16F ); InsertLoadFunction(&map, GL_R8, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8_UNORM, LoadToNative<GLubyte, 1> );
InsertLoadFunction(&map, GL_R11F_G11F_B10F, GL_FLOAT, LoadRGB32FToRG11B10F ); InsertLoadFunction(&map, GL_R8_SNORM, GL_BYTE, DXGI_FORMAT_R8_SNORM, LoadToNative<GLbyte, 1> );
InsertLoadFunction(&map, GL_RGB9_E5, GL_FLOAT, LoadRGB32FToRGB9E5 ); InsertLoadFunction(&map, GL_R16F, GL_HALF_FLOAT, DXGI_FORMAT_R16_FLOAT, LoadToNative<GLhalf, 1> );
InsertLoadFunction(&map, GL_RGB8UI, GL_UNSIGNED_BYTE, LoadToNative3To4<GLubyte, 0x01> ); InsertLoadFunction(&map, GL_R16F, GL_HALF_FLOAT_OES, DXGI_FORMAT_R16_FLOAT, LoadToNative<GLhalf, 1> );
InsertLoadFunction(&map, GL_RGB8I, GL_BYTE, LoadToNative3To4<GLbyte, 0x01> ); InsertLoadFunction(&map, GL_R32F, GL_FLOAT, DXGI_FORMAT_R32_FLOAT, LoadToNative<GLfloat, 1> );
InsertLoadFunction(&map, GL_RGB16UI, GL_UNSIGNED_SHORT, LoadToNative3To4<GLushort, 0x0001> ); InsertLoadFunction(&map, GL_R16F, GL_FLOAT, DXGI_FORMAT_R16_FLOAT, Load32FTo16F<1> );
InsertLoadFunction(&map, GL_RGB16I, GL_SHORT, LoadToNative3To4<GLshort, 0x0001> ); InsertLoadFunction(&map, GL_R8UI, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8_UINT, LoadToNative<GLubyte, 1> );
InsertLoadFunction(&map, GL_RGB32UI, GL_UNSIGNED_INT, LoadToNative3To4<GLuint, 0x00000001> ); InsertLoadFunction(&map, GL_R8I, GL_BYTE, DXGI_FORMAT_R8_SINT, LoadToNative<GLbyte, 1> );
InsertLoadFunction(&map, GL_RGB32I, GL_INT, LoadToNative3To4<GLint, 0x00000001> ); InsertLoadFunction(&map, GL_R16UI, GL_UNSIGNED_SHORT, DXGI_FORMAT_R16_UINT, LoadToNative<GLushort, 1> );
InsertLoadFunction(&map, GL_RG8, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 2> ); InsertLoadFunction(&map, GL_R16I, GL_SHORT, DXGI_FORMAT_R16_SINT, LoadToNative<GLshort, 1> );
InsertLoadFunction(&map, GL_RG8_SNORM, GL_BYTE, LoadToNative<GLbyte, 2> ); InsertLoadFunction(&map, GL_R32UI, GL_UNSIGNED_INT, DXGI_FORMAT_R32_UINT, LoadToNative<GLuint, 1> );
InsertLoadFunction(&map, GL_RG16F, GL_HALF_FLOAT, LoadToNative<GLhalf, 2> ); InsertLoadFunction(&map, GL_R32I, GL_INT, DXGI_FORMAT_R32_SINT, LoadToNative<GLint, 1> );
InsertLoadFunction(&map, GL_RG16F, GL_HALF_FLOAT_OES, LoadToNative<GLhalf, 2> );
InsertLoadFunction(&map, GL_RG32F, GL_FLOAT, LoadToNative<GLfloat, 2> ); InsertLoadFunction(&map, GL_DEPTH_COMPONENT16, GL_UNSIGNED_SHORT, DXGI_FORMAT_R16_TYPELESS, LoadToNative<GLushort, 1> );
InsertLoadFunction(&map, GL_RG16F, GL_FLOAT, Load32FTo16F<2> ); InsertLoadFunction(&map, GL_DEPTH_COMPONENT16, GL_UNSIGNED_SHORT, DXGI_FORMAT_D16_UNORM, LoadToNative<GLushort, 1> );
InsertLoadFunction(&map, GL_RG8UI, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 2> ); InsertLoadFunction(&map, GL_DEPTH_COMPONENT24, GL_UNSIGNED_INT, DXGI_FORMAT_R24G8_TYPELESS, LoadR32ToR24G8 );
InsertLoadFunction(&map, GL_RG8I, GL_BYTE, LoadToNative<GLbyte, 2> ); InsertLoadFunction(&map, GL_DEPTH_COMPONENT24, GL_UNSIGNED_INT, DXGI_FORMAT_D24_UNORM_S8_UINT, LoadR32ToR24G8 );
InsertLoadFunction(&map, GL_RG16UI, GL_UNSIGNED_SHORT, LoadToNative<GLushort, 2> ); InsertLoadFunction(&map, GL_DEPTH_COMPONENT16, GL_UNSIGNED_INT, DXGI_FORMAT_R16_TYPELESS, LoadR32ToR16 );
InsertLoadFunction(&map, GL_RG16I, GL_SHORT, LoadToNative<GLshort, 2> ); InsertLoadFunction(&map, GL_DEPTH_COMPONENT32F, GL_FLOAT, DXGI_FORMAT_R32_TYPELESS, LoadToNative<GLfloat, 1> );
InsertLoadFunction(&map, GL_RG32UI, GL_UNSIGNED_INT, LoadToNative<GLuint, 2> ); InsertLoadFunction(&map, GL_DEPTH_COMPONENT32F, GL_FLOAT, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_RG32I, GL_INT, LoadToNative<GLint, 2> ); InsertLoadFunction(&map, GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8, DXGI_FORMAT_R24G8_TYPELESS, LoadR32ToR24G8 );
InsertLoadFunction(&map, GL_R8, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 1> ); InsertLoadFunction(&map, GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8, DXGI_FORMAT_D24_UNORM_S8_UINT, LoadR32ToR24G8 );
InsertLoadFunction(&map, GL_R8_SNORM, GL_BYTE, LoadToNative<GLbyte, 1> ); InsertLoadFunction(&map, GL_DEPTH32F_STENCIL8, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, DXGI_FORMAT_R32G8X24_TYPELESS, LoadToNative<GLuint, 2> );
InsertLoadFunction(&map, GL_R16F, GL_HALF_FLOAT, LoadToNative<GLhalf, 1> ); InsertLoadFunction(&map, GL_DEPTH32F_STENCIL8, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_R16F, GL_HALF_FLOAT_OES, LoadToNative<GLhalf, 1> ); InsertLoadFunction(&map, GL_STENCIL_INDEX8, DXGI_FORMAT_R24G8_TYPELESS, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_R32F, GL_FLOAT, LoadToNative<GLfloat, 1> ); InsertLoadFunction(&map, GL_STENCIL_INDEX8, DXGI_FORMAT_D24_UNORM_S8_UINT, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_R16F, GL_FLOAT, Load32FTo16F<1> );
InsertLoadFunction(&map, GL_R8UI, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 1> );
InsertLoadFunction(&map, GL_R8I, GL_BYTE, LoadToNative<GLbyte, 1> );
InsertLoadFunction(&map, GL_R16UI, GL_UNSIGNED_SHORT, LoadToNative<GLushort, 1> );
InsertLoadFunction(&map, GL_R16I, GL_SHORT, LoadToNative<GLshort, 1> );
InsertLoadFunction(&map, GL_R32UI, GL_UNSIGNED_INT, LoadToNative<GLuint, 1> );
InsertLoadFunction(&map, GL_R32I, GL_INT, LoadToNative<GLint, 1> );
InsertLoadFunction(&map, GL_DEPTH_COMPONENT16, GL_UNSIGNED_SHORT, LoadToNative<GLushort, 1> );
InsertLoadFunction(&map, GL_DEPTH_COMPONENT24, GL_UNSIGNED_INT, LoadR32ToR24G8 );
InsertLoadFunction(&map, GL_DEPTH_COMPONENT16, GL_UNSIGNED_INT, LoadR32ToR16 );
InsertLoadFunction(&map, GL_DEPTH_COMPONENT32F, GL_FLOAT, LoadToNative<GLfloat, 1> );
InsertLoadFunction(&map, GL_DEPTH24_STENCIL8, GL_UNSIGNED_INT_24_8, LoadR32ToR24G8 );
InsertLoadFunction(&map, GL_DEPTH32F_STENCIL8, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, LoadToNative<GLuint, 2> );
// Unsized formats // Unsized formats
// Load functions are unreachable because they are converted to sized internal formats based on // Load functions are unreachable because they are converted to sized internal formats based on
// the format and type before loading takes place. // the format and type before loading takes place.
InsertLoadFunction(&map, GL_RGBA, GL_UNSIGNED_BYTE, UnreachableLoadFunction ); InsertLoadFunction(&map, GL_RGBA, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnreachableLoadFunction );
InsertLoadFunction(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, UnreachableLoadFunction ); InsertLoadFunction(&map, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, DXGI_FORMAT_UNKNOWN, UnreachableLoadFunction );
InsertLoadFunction(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, UnreachableLoadFunction ); InsertLoadFunction(&map, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, DXGI_FORMAT_UNKNOWN, UnreachableLoadFunction );
InsertLoadFunction(&map, GL_RGB, GL_UNSIGNED_BYTE, UnreachableLoadFunction ); InsertLoadFunction(&map, GL_RGB, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnreachableLoadFunction );
InsertLoadFunction(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, UnreachableLoadFunction ); InsertLoadFunction(&map, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, DXGI_FORMAT_UNKNOWN, UnreachableLoadFunction );
InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, UnreachableLoadFunction ); InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnreachableLoadFunction );
InsertLoadFunction(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, UnreachableLoadFunction ); InsertLoadFunction(&map, GL_LUMINANCE, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnreachableLoadFunction );
InsertLoadFunction(&map, GL_ALPHA, GL_UNSIGNED_BYTE, UnreachableLoadFunction ); InsertLoadFunction(&map, GL_ALPHA, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnreachableLoadFunction );
InsertLoadFunction(&map, GL_BGRA_EXT, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnreachableLoadFunction );
// From GL_OES_texture_float // From GL_OES_texture_float
InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, LoadLA32FToRGBA32F ); InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, LoadLA32FToRGBA32F );
InsertLoadFunction(&map, GL_LUMINANCE, GL_FLOAT, LoadL32FToRGBA32F ); InsertLoadFunction(&map, GL_LUMINANCE, GL_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, LoadL32FToRGBA32F );
InsertLoadFunction(&map, GL_ALPHA, GL_FLOAT, LoadA32FToRGBA32F ); InsertLoadFunction(&map, GL_ALPHA, GL_FLOAT, DXGI_FORMAT_R32G32B32A32_FLOAT, LoadA32FToRGBA32F );
// From GL_OES_texture_half_float // From GL_OES_texture_half_float
InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, LoadLA16FToRGBA16F ); InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadLA16FToRGBA16F );
InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, LoadLA16FToRGBA16F ); InsertLoadFunction(&map, GL_LUMINANCE_ALPHA, GL_HALF_FLOAT_OES, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadLA16FToRGBA16F );
InsertLoadFunction(&map, GL_LUMINANCE, GL_HALF_FLOAT, LoadL16FToRGBA16F ); InsertLoadFunction(&map, GL_LUMINANCE, GL_HALF_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadL16FToRGBA16F );
InsertLoadFunction(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, LoadL16FToRGBA16F ); InsertLoadFunction(&map, GL_LUMINANCE, GL_HALF_FLOAT_OES, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadL16FToRGBA16F );
InsertLoadFunction(&map, GL_ALPHA, GL_HALF_FLOAT, LoadA16FToRGBA16F ); InsertLoadFunction(&map, GL_ALPHA, GL_HALF_FLOAT, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadA16FToRGBA16F );
InsertLoadFunction(&map, GL_ALPHA, GL_HALF_FLOAT_OES, LoadA16FToRGBA16F ); InsertLoadFunction(&map, GL_ALPHA, GL_HALF_FLOAT_OES, DXGI_FORMAT_R16G16B16A16_FLOAT, LoadA16FToRGBA16F );
// From GL_EXT_texture_storage // From GL_EXT_texture_storage
// GL_ALPHA8_EXT GL_UNSIGNED_BYTE is in the feature-level-specific load function maps, due to differences between 9_3 and 10_0+ InsertLoadFunction(&map, GL_ALPHA8_EXT, GL_UNSIGNED_BYTE, DXGI_FORMAT_A8_UNORM, LoadToNative<GLubyte, 1> );
InsertLoadFunction(&map, GL_LUMINANCE8_EXT, GL_UNSIGNED_BYTE, LoadL8ToRGBA8 ); InsertLoadFunction(&map, GL_ALPHA8_EXT, GL_UNSIGNED_BYTE, DXGI_FORMAT_R8G8B8A8_UNORM, LoadA8ToRGBA8 );
InsertLoadFunction(&map, GL_LUMINANCE8_ALPHA8_EXT, GL_UNSIGNED_BYTE, LoadLA8ToRGBA8 ); InsertLoadFunction(&map, GL_LUMINANCE8_EXT, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, LoadL8ToRGBA8 );
InsertLoadFunction(&map, GL_ALPHA32F_EXT, GL_FLOAT, LoadA32FToRGBA32F ); InsertLoadFunction(&map, GL_LUMINANCE8_ALPHA8_EXT, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, LoadLA8ToRGBA8 );
InsertLoadFunction(&map, GL_LUMINANCE32F_EXT, GL_FLOAT, LoadL32FToRGBA32F ); InsertLoadFunction(&map, GL_ALPHA32F_EXT, GL_FLOAT, DXGI_FORMAT_UNKNOWN, LoadA32FToRGBA32F );
InsertLoadFunction(&map, GL_LUMINANCE_ALPHA32F_EXT, GL_FLOAT, LoadLA32FToRGBA32F ); InsertLoadFunction(&map, GL_LUMINANCE32F_EXT, GL_FLOAT, DXGI_FORMAT_UNKNOWN, LoadL32FToRGBA32F );
InsertLoadFunction(&map, GL_ALPHA16F_EXT, GL_HALF_FLOAT, LoadA16FToRGBA16F ); InsertLoadFunction(&map, GL_LUMINANCE_ALPHA32F_EXT, GL_FLOAT, DXGI_FORMAT_UNKNOWN, LoadLA32FToRGBA32F );
InsertLoadFunction(&map, GL_ALPHA16F_EXT, GL_HALF_FLOAT_OES, LoadA16FToRGBA16F ); InsertLoadFunction(&map, GL_ALPHA16F_EXT, GL_HALF_FLOAT, DXGI_FORMAT_UNKNOWN, LoadA16FToRGBA16F );
InsertLoadFunction(&map, GL_LUMINANCE16F_EXT, GL_HALF_FLOAT, LoadL16FToRGBA16F ); InsertLoadFunction(&map, GL_ALPHA16F_EXT, GL_HALF_FLOAT_OES, DXGI_FORMAT_UNKNOWN, LoadA16FToRGBA16F );
InsertLoadFunction(&map, GL_LUMINANCE16F_EXT, GL_HALF_FLOAT_OES, LoadL16FToRGBA16F ); InsertLoadFunction(&map, GL_LUMINANCE16F_EXT, GL_HALF_FLOAT, DXGI_FORMAT_UNKNOWN, LoadL16FToRGBA16F );
InsertLoadFunction(&map, GL_LUMINANCE_ALPHA16F_EXT, GL_HALF_FLOAT, LoadLA16FToRGBA16F ); InsertLoadFunction(&map, GL_LUMINANCE16F_EXT, GL_HALF_FLOAT_OES, DXGI_FORMAT_UNKNOWN, LoadL16FToRGBA16F );
InsertLoadFunction(&map, GL_LUMINANCE_ALPHA16F_EXT, GL_HALF_FLOAT_OES, LoadLA16FToRGBA16F ); InsertLoadFunction(&map, GL_LUMINANCE_ALPHA16F_EXT, GL_HALF_FLOAT, DXGI_FORMAT_UNKNOWN, LoadLA16FToRGBA16F );
InsertLoadFunction(&map, GL_LUMINANCE_ALPHA16F_EXT, GL_HALF_FLOAT_OES, DXGI_FORMAT_UNKNOWN, LoadLA16FToRGBA16F );
// From GL_ANGLE_depth_texture // From GL_ANGLE_depth_texture
InsertLoadFunction(&map, GL_DEPTH_COMPONENT32_OES, GL_UNSIGNED_INT, LoadR32ToR24G8 ); InsertLoadFunction(&map, GL_DEPTH_COMPONENT32_OES, GL_UNSIGNED_INT, DXGI_FORMAT_UNKNOWN, LoadR32ToR24G8 );
// From GL_EXT_texture_format_BGRA8888 // From GL_EXT_texture_format_BGRA8888
InsertLoadFunction(&map, GL_BGRA8_EXT, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> ); InsertLoadFunction(&map, GL_BGRA8_EXT, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, LoadToNative<GLubyte, 4> );
InsertLoadFunction(&map, GL_BGRA4_ANGLEX, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, LoadRGBA4ToRGBA8 ); InsertLoadFunction(&map, GL_BGRA4_ANGLEX, GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT, DXGI_FORMAT_UNKNOWN, LoadRGBA4ToRGBA8 );
InsertLoadFunction(&map, GL_BGRA4_ANGLEX, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> ); InsertLoadFunction(&map, GL_BGRA4_ANGLEX, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, LoadToNative<GLubyte, 4> );
InsertLoadFunction(&map, GL_BGR5_A1_ANGLEX, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, LoadRGB5A1ToRGBA8 ); InsertLoadFunction(&map, GL_BGR5_A1_ANGLEX, GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT, DXGI_FORMAT_UNKNOWN, LoadRGB5A1ToRGBA8 );
InsertLoadFunction(&map, GL_BGR5_A1_ANGLEX, GL_UNSIGNED_BYTE, LoadToNative<GLubyte, 4> ); InsertLoadFunction(&map, GL_BGR5_A1_ANGLEX, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, LoadToNative<GLubyte, 4> );
// Compressed formats // Compressed formats
// From ES 3.0.1 spec, table 3.16 // From ES 3.0.1 spec, table 3.16
// | Internal format | Type | Load function | // | Internal format | Type | Load function |
InsertLoadFunction(&map, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_R11_EAC, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_SIGNED_R11_EAC, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_RG11_EAC, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_SIGNED_RG11_EAC, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_RGB8_ETC2, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_SRGB8_ETC2, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_RGBA8_ETC2_EAC, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
InsertLoadFunction(&map, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, UnimplementedLoadFunction ); InsertLoadFunction(&map, GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, UnimplementedLoadFunction );
// From GL_EXT_texture_compression_dxt1 // From GL_EXT_texture_compression_dxt1
InsertLoadFunction(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, LoadCompressedToNative<4, 4, 8>); InsertLoadFunction(&map, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, LoadCompressedToNative<4, 4, 8> );
InsertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, LoadCompressedToNative<4, 4, 8>); InsertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, LoadCompressedToNative<4, 4, 8> );
// From GL_ANGLE_texture_compression_dxt3 // From GL_ANGLE_texture_compression_dxt3
InsertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, LoadCompressedToNative<4, 4, 16>); InsertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT3_ANGLE, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, LoadCompressedToNative<4, 4, 16> );
// From GL_ANGLE_texture_compression_dxt5 // From GL_ANGLE_texture_compression_dxt5
InsertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, LoadCompressedToNative<4, 4, 16>); InsertLoadFunction(&map, GL_COMPRESSED_RGBA_S3TC_DXT5_ANGLE, GL_UNSIGNED_BYTE, DXGI_FORMAT_UNKNOWN, LoadCompressedToNative<4, 4, 16> );
return map; return map;
} }
...@@ -759,7 +751,7 @@ TextureFormat::TextureFormat() ...@@ -759,7 +751,7 @@ TextureFormat::TextureFormat()
{ {
} }
static inline void InsertD3D11FormatInfoBase(D3D11ES3FormatMap *formatMap, const D3D11LoadFunctionMap &flLoadFunctions, GLenum internalFormat, DXGI_FORMAT texFormat, static inline void InsertD3D11FormatInfo(D3D11ES3FormatMap *formatMap, GLenum internalFormat, DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat) DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat)
{ {
TextureFormat info; TextureFormat info;
...@@ -844,48 +836,29 @@ static inline void InsertD3D11FormatInfoBase(D3D11ES3FormatMap *formatMap, const ...@@ -844,48 +836,29 @@ static inline void InsertD3D11FormatInfoBase(D3D11ES3FormatMap *formatMap, const
InternalFormatInitializerMap::const_iterator initializerIter = initializerMap.find(internalFormat); InternalFormatInitializerMap::const_iterator initializerIter = initializerMap.find(internalFormat);
info.dataInitializerFunction = (initializerIter != initializerMap.end()) ? initializerIter->second : NULL; info.dataInitializerFunction = (initializerIter != initializerMap.end()) ? initializerIter->second : NULL;
// Gather all the load functions for this internal format from the base list // Gather all the load functions for this internal format
static const D3D11LoadFunctionMap loadFunctions = BuildBaseD3D11LoadFunctionMap(); static const D3D11LoadFunctionMap loadFunctions = BuildD3D11LoadFunctionMap();
D3D11LoadFunctionMap::const_iterator loadFunctionIter = loadFunctions.find(internalFormat); D3D11LoadFunctionMap::const_iterator loadFunctionIter = loadFunctions.find(internalFormat);
if (loadFunctionIter != loadFunctions.end()) if (loadFunctionIter != loadFunctions.end())
{ {
const std::vector<TypeLoadFunctionPair> &loadFunctionVector = loadFunctionIter->second; const std::vector<GLTypeDXGIFunctionPair> &loadFunctionVector = loadFunctionIter->second;
for (size_t i = 0; i < loadFunctionVector.size(); i++) for (size_t i = 0; i < loadFunctionVector.size(); i++)
{ {
DxgiFormatLoadFunctionPair formatFuncPair = loadFunctionVector[i].second;
GLenum type = loadFunctionVector[i].first; GLenum type = loadFunctionVector[i].first;
LoadImageFunction function = loadFunctionVector[i].second; DXGI_FORMAT dxgiFormat = formatFuncPair.first;
info.loadFunctions.insert(std::make_pair(type, function)); rx::LoadImageFunction loadFunc = formatFuncPair.second;
}
}
// Gather load functions for this internal format from the feature-level-specific list if (dxgiFormat == texFormat || dxgiFormat == DXGI_FORMAT_UNKNOWN)
D3D11LoadFunctionMap::const_iterator flLoadFunctionIter = flLoadFunctions.find(internalFormat);
if (flLoadFunctionIter != flLoadFunctions.end())
{
const std::vector<TypeLoadFunctionPair> &flLoadFunctionVector = flLoadFunctionIter->second;
for (size_t i = 0; i < flLoadFunctionVector.size(); i++)
{ {
GLenum type = flLoadFunctionVector[i].first; info.loadFunctions.insert(std::make_pair(type, loadFunc));
LoadImageFunction function = flLoadFunctionVector[i].second; }
info.loadFunctions.insert(std::make_pair(type, function));
} }
} }
formatMap->insert(std::make_pair(internalFormat, info)); ASSERT(info.loadFunctions.size() != 0 || internalFormat == GL_NONE);
}
static inline void InsertD3D11_FL9_3_FormatInfo(D3D11ES3FormatMap *map, GLenum internalFormat, DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat)
{
static const D3D11LoadFunctionMap flLoadFunctions = BuildD3D11_FL9_3_LoadFunctionMap();
InsertD3D11FormatInfoBase(map, flLoadFunctions, internalFormat, texFormat, srvFormat, rtvFormat, dsvFormat);
}
static inline void InsertD3D11FormatInfo(D3D11ES3FormatMap *map, GLenum internalFormat, DXGI_FORMAT texFormat, formatMap->insert(std::make_pair(internalFormat, info));
DXGI_FORMAT srvFormat, DXGI_FORMAT rtvFormat, DXGI_FORMAT dsvFormat)
{
static const D3D11LoadFunctionMap flLoadFunctions = BuildD3D11_FL10_0Plus_LoadFunctionMap();
InsertD3D11FormatInfoBase(map, flLoadFunctions, internalFormat, texFormat, srvFormat, rtvFormat, dsvFormat);
} }
static D3D11ES3FormatMap BuildD3D11_FL9_3FormatOverrideMap() static D3D11ES3FormatMap BuildD3D11_FL9_3FormatOverrideMap()
...@@ -899,14 +872,14 @@ static D3D11ES3FormatMap BuildD3D11_FL9_3FormatOverrideMap() ...@@ -899,14 +872,14 @@ static D3D11ES3FormatMap BuildD3D11_FL9_3FormatOverrideMap()
D3D11ES3FormatMap map; D3D11ES3FormatMap map;
// | GL internal format | D3D11 texture format | D3D11 SRV format | D3D11 RTV format | D3D11 DSV format // | GL internal format | D3D11 texture format | D3D11 SRV format | D3D11 RTV format | D3D11 DSV format
InsertD3D11_FL9_3_FormatInfo(&map, GL_ALPHA, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN); InsertD3D11FormatInfo(&map, GL_ALPHA, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
InsertD3D11_FL9_3_FormatInfo(&map, GL_ALPHA8_EXT, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN); InsertD3D11FormatInfo(&map, GL_ALPHA8_EXT, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_R8G8B8A8_UNORM, DXGI_FORMAT_UNKNOWN);
InsertD3D11_FL9_3_FormatInfo(&map, GL_DEPTH_COMPONENT16, DXGI_FORMAT_D16_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D16_UNORM); InsertD3D11FormatInfo(&map, GL_DEPTH_COMPONENT16, DXGI_FORMAT_D16_UNORM, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D16_UNORM);
InsertD3D11_FL9_3_FormatInfo(&map, GL_DEPTH_COMPONENT24, DXGI_FORMAT_D24_UNORM_S8_UINT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT); InsertD3D11FormatInfo(&map, GL_DEPTH_COMPONENT24, DXGI_FORMAT_D24_UNORM_S8_UINT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT);
InsertD3D11_FL9_3_FormatInfo(&map, GL_DEPTH_COMPONENT32F, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN); InsertD3D11FormatInfo(&map, GL_DEPTH_COMPONENT32F, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
InsertD3D11_FL9_3_FormatInfo(&map, GL_DEPTH24_STENCIL8, DXGI_FORMAT_D24_UNORM_S8_UINT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT); InsertD3D11FormatInfo(&map, GL_DEPTH24_STENCIL8, DXGI_FORMAT_D24_UNORM_S8_UINT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT);
InsertD3D11_FL9_3_FormatInfo(&map, GL_DEPTH32F_STENCIL8, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN); InsertD3D11FormatInfo(&map, GL_DEPTH32F_STENCIL8, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN);
InsertD3D11_FL9_3_FormatInfo(&map, GL_STENCIL_INDEX8, DXGI_FORMAT_D24_UNORM_S8_UINT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT); InsertD3D11FormatInfo(&map, GL_STENCIL_INDEX8, DXGI_FORMAT_D24_UNORM_S8_UINT, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_UNKNOWN, DXGI_FORMAT_D24_UNORM_S8_UINT);
return map; return map;
} }
......
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