Commit 051dbc79 by Geoff Lang

Create a formatutilsD3D and move some functions from formatutils.

BUG=angle:681 Change-Id: I694073c50dccd05c3117761e446eba0d15c03293 Reviewed-on: https://chromium-review.googlesource.com/238480Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent e50bf15f
...@@ -260,14 +260,6 @@ struct VertexFormat ...@@ -260,14 +260,6 @@ struct VertexFormat
namespace rx namespace rx
{ {
enum VertexConversionType
{
VERTEX_CONVERT_NONE = 0,
VERTEX_CONVERT_CPU = 1,
VERTEX_CONVERT_GPU = 2,
VERTEX_CONVERT_BOTH = 3
};
enum VendorID : uint32_t enum VendorID : uint32_t
{ {
VENDOR_ID_AMD = 0x1002, VENDOR_ID_AMD = 0x1002,
......
...@@ -17,35 +17,9 @@ ...@@ -17,35 +17,9 @@
#include <cstddef> #include <cstddef>
#include <stdint.h> #include <stdint.h>
typedef void (*MipGenerationFunction)(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
uint8_t *destData, size_t destRowPitch, size_t destDepthPitch);
typedef void (*LoadImageFunction)(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*VertexCopyFunction)(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
namespace gl namespace gl
{ {
struct FormatType
{
FormatType();
GLenum internalFormat;
ColorWriteFunction colorWriteFunction;
};
const FormatType &GetFormatTypeInfo(GLenum format, GLenum type);
struct Type struct Type
{ {
Type(); Type();
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "libANGLE/Data.h" #include "libANGLE/Data.h"
#include "libANGLE/renderer/Renderer.h" #include "libANGLE/renderer/Renderer.h"
#include "libANGLE/renderer/d3d/formatutilsD3D.h"
#include "libANGLE/renderer/d3d/MemoryBuffer.h" #include "libANGLE/renderer/d3d/MemoryBuffer.h"
#include "libANGLE/renderer/d3d/d3d11/NativeWindow.h" #include "libANGLE/renderer/d3d/d3d11/NativeWindow.h"
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/formatutils.h"
#include "common/utilities.h" #include "common/utilities.h"
......
...@@ -199,7 +199,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpac ...@@ -199,7 +199,7 @@ gl::Error PixelTransfer11::copyBufferToTexture(const gl::PixelUnpackState &unpac
// The SRV must be in the proper read format, which may be different from the destination format // The SRV must be in the proper read format, which may be different from the destination format
// EG: for half float data, we can load full precision floats with implicit conversion // EG: for half float data, we can load full precision floats with implicit conversion
GLenum unsizedFormat = gl::GetInternalFormatInfo(destinationFormat).format; GLenum unsizedFormat = gl::GetInternalFormatInfo(destinationFormat).format;
GLenum sourceFormat = gl::GetFormatTypeInfo(unsizedFormat, sourcePixelsType).internalFormat; GLenum sourceFormat = gl::GetSizedInternalFormat(unsizedFormat, sourcePixelsType);
const d3d11::TextureFormat &sourceFormatInfo = d3d11::GetTextureFormatInfo(sourceFormat, mRenderer->getFeatureLevel()); const d3d11::TextureFormat &sourceFormatInfo = d3d11::GetTextureFormatInfo(sourceFormat, mRenderer->getFeatureLevel());
DXGI_FORMAT srvFormat = sourceFormatInfo.srvFormat; DXGI_FORMAT srvFormat = sourceFormatInfo.srvFormat;
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/State.h" #include "libANGLE/State.h"
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/d3d/CompilerD3D.h" #include "libANGLE/renderer/d3d/CompilerD3D.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h" #include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/IndexDataManager.h" #include "libANGLE/renderer/d3d/IndexDataManager.h"
...@@ -2994,8 +2995,8 @@ gl::Error Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsP ...@@ -2994,8 +2995,8 @@ gl::Error Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsP
const d3d11::DXGIFormat &sourceDXGIFormatInfo = d3d11::GetDXGIFormatInfo(textureDesc.Format); const d3d11::DXGIFormat &sourceDXGIFormatInfo = d3d11::GetDXGIFormatInfo(textureDesc.Format);
ColorCopyFunction fastCopyFunc = sourceDXGIFormatInfo.getFastCopyFunction(params.format, params.type); ColorCopyFunction fastCopyFunc = sourceDXGIFormatInfo.getFastCopyFunction(params.format, params.type);
const gl::FormatType &destFormatTypeInfo = gl::GetFormatTypeInfo(params.format, params.type); GLenum sizedDestInternalFormat = gl::GetSizedInternalFormat(params.format, params.type);
const gl::InternalFormat &destFormatInfo = gl::GetInternalFormatInfo(destFormatTypeInfo.internalFormat); const gl::InternalFormat &destFormatInfo = gl::GetInternalFormatInfo(sizedDestInternalFormat);
if (fastCopyFunc) if (fastCopyFunc)
{ {
...@@ -3013,6 +3014,9 @@ gl::Error Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsP ...@@ -3013,6 +3014,9 @@ gl::Error Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsP
} }
else else
{ {
ColorReadFunction colorReadFunction = sourceDXGIFormatInfo.colorReadFunction;
ColorWriteFunction colorWriteFunction = GetColorWriteFunction(params.format, params.type);
uint8_t temp[16]; // Maximum size of any Color<T> type used. uint8_t temp[16]; // Maximum size of any Color<T> type used.
META_ASSERT(sizeof(temp) >= sizeof(gl::ColorF) && META_ASSERT(sizeof(temp) >= sizeof(gl::ColorF) &&
sizeof(temp) >= sizeof(gl::ColorUI) && sizeof(temp) >= sizeof(gl::ColorUI) &&
...@@ -3027,8 +3031,8 @@ gl::Error Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsP ...@@ -3027,8 +3031,8 @@ gl::Error Renderer11::packPixels(ID3D11Texture2D *readTexture, const PackPixelsP
// readFunc and writeFunc will be using the same type of color, CopyTexImage // readFunc and writeFunc will be using the same type of color, CopyTexImage
// will not allow the copy otherwise. // will not allow the copy otherwise.
sourceDXGIFormatInfo.colorReadFunction(src, temp); colorReadFunction(src, temp);
destFormatTypeInfo.colorWriteFunction(temp, dest); colorWriteFunction(temp, dest);
} }
} }
} }
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <tuple> #include <tuple>
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h" #include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h" #include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/d3d/d3d11/SwapChain11.h" #include "libANGLE/renderer/d3d/d3d11/SwapChain11.h"
......
...@@ -8,11 +8,13 @@ ...@@ -8,11 +8,13 @@
// formats. // formats.
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/copyvertex.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/Renderer.h"
#include "libANGLE/renderer/d3d/copyimage.h" #include "libANGLE/renderer/d3d/copyimage.h"
#include "libANGLE/renderer/d3d/generatemip.h" #include "libANGLE/renderer/d3d/generatemip.h"
#include "libANGLE/renderer/d3d/loadimage.h" #include "libANGLE/renderer/d3d/loadimage.h"
#include "libANGLE/renderer/Renderer.h" #include "libANGLE/renderer/d3d/d3d11/copyvertex.h"
namespace rx namespace rx
{ {
......
...@@ -10,7 +10,10 @@ ...@@ -10,7 +10,10 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D11_FORMATUTILS11_H_ #ifndef LIBANGLE_RENDERER_D3D_D3D11_FORMATUTILS11_H_
#define LIBANGLE_RENDERER_D3D_D3D11_FORMATUTILS11_H_ #define LIBANGLE_RENDERER_D3D_D3D11_FORMATUTILS11_H_
#include "libANGLE/formatutils.h" #include "libANGLE/renderer/d3d/formatutilsD3D.h"
#include "libANGLE/angletypes.h"
#include "common/platform.h"
#include <map> #include <map>
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h" #include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h" #include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/Workarounds.h" #include "libANGLE/renderer/Workarounds.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h" #include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h" #include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/TextureD3D.h" #include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
...@@ -185,8 +186,8 @@ gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLe ...@@ -185,8 +186,8 @@ gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLe
const d3d9::D3DFormat &sourceD3DFormatInfo = d3d9::GetD3DFormatInfo(desc.Format); const d3d9::D3DFormat &sourceD3DFormatInfo = d3d9::GetD3DFormatInfo(desc.Format);
ColorCopyFunction fastCopyFunc = sourceD3DFormatInfo.getFastCopyFunction(format, type); ColorCopyFunction fastCopyFunc = sourceD3DFormatInfo.getFastCopyFunction(format, type);
const gl::FormatType &destFormatTypeInfo = gl::GetFormatTypeInfo(format, type); GLenum sizedDestInternalFormat = gl::GetSizedInternalFormat(format, type);
const gl::InternalFormat &destFormatInfo = gl::GetInternalFormatInfo(destFormatTypeInfo.internalFormat); const gl::InternalFormat &destFormatInfo = gl::GetInternalFormatInfo(sizedDestInternalFormat);
if (fastCopyFunc) if (fastCopyFunc)
{ {
...@@ -204,6 +205,9 @@ gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLe ...@@ -204,6 +205,9 @@ gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLe
} }
else else
{ {
ColorReadFunction colorReadFunction = sourceD3DFormatInfo.colorReadFunction;
ColorWriteFunction colorWriteFunction = GetColorWriteFunction(format, type);
uint8_t temp[sizeof(gl::ColorF)]; uint8_t temp[sizeof(gl::ColorF)];
for (int y = 0; y < rect.bottom - rect.top; y++) for (int y = 0; y < rect.bottom - rect.top; y++)
{ {
...@@ -214,8 +218,8 @@ gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLe ...@@ -214,8 +218,8 @@ gl::Error Framebuffer9::readPixels(const gl::Rectangle &area, GLenum format, GLe
// readFunc and writeFunc will be using the same type of color, CopyTexImage // readFunc and writeFunc will be using the same type of color, CopyTexImage
// will not allow the copy otherwise. // will not allow the copy otherwise.
sourceD3DFormatInfo.colorReadFunction(src, temp); colorReadFunction(src, temp);
destFormatTypeInfo.colorWriteFunction(temp, dest); colorWriteFunction(temp, dest);
} }
} }
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h" #include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h" #include "libANGLE/renderer/d3d/d3d9/RenderTarget9.h"
#include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h" #include "libANGLE/renderer/d3d/d3d9/TextureStorage9.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/features.h" #include "libANGLE/features.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/renderer/d3d/CompilerD3D.h" #include "libANGLE/renderer/d3d/CompilerD3D.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h" #include "libANGLE/renderer/d3d/FramebufferD3D.h"
#include "libANGLE/renderer/d3d/IndexDataManager.h" #include "libANGLE/renderer/d3d/IndexDataManager.h"
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h" #include "libANGLE/renderer/d3d/d3d9/renderer9_utils.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h" #include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/renderer/d3d/TextureD3D.h" #include "libANGLE/renderer/d3d/TextureD3D.h"
#include "libANGLE/formatutils.h"
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
namespace rx namespace rx
......
...@@ -7,10 +7,10 @@ ...@@ -7,10 +7,10 @@
// formatutils9.cpp: Queries for GL image formats and their translations to D3D9 // formatutils9.cpp: Queries for GL image formats and their translations to D3D9
// formats. // formats.
#include "libANGLE/renderer/d3d/copyimage.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h" #include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/renderer/d3d/d3d9/Renderer9.h" #include "libANGLE/renderer/d3d/d3d9/Renderer9.h"
#include "libANGLE/renderer/d3d/d3d9/vertexconversion.h" #include "libANGLE/renderer/d3d/d3d9/vertexconversion.h"
#include "libANGLE/renderer/d3d/copyimage.h"
#include "libANGLE/renderer/d3d/generatemip.h" #include "libANGLE/renderer/d3d/generatemip.h"
#include "libANGLE/renderer/d3d/loadimage.h" #include "libANGLE/renderer/d3d/loadimage.h"
......
...@@ -10,7 +10,10 @@ ...@@ -10,7 +10,10 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D9_FORMATUTILS9_H_ #ifndef LIBANGLE_RENDERER_D3D_D3D9_FORMATUTILS9_H_
#define LIBANGLE_RENDERER_D3D_D3D9_FORMATUTILS9_H_ #define LIBANGLE_RENDERER_D3D_D3D9_FORMATUTILS9_H_
#include "libANGLE/formatutils.h" #include "libANGLE/renderer/d3d/formatutilsD3D.h"
#include "libANGLE/angletypes.h"
#include "common/platform.h"
#include <map> #include <map>
......
//
// Copyright (c) 2015 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.
//
// formatutils9.h: Queries for GL image formats and their translations to D3D
// formats.
#ifndef LIBANGLE_RENDERER_D3D_FORMATUTILSD3D_H_
#define LIBANGLE_RENDERER_D3D_FORMATUTILSD3D_H_
#include "angle_gl.h"
#include <cstddef>
#include <stdint.h>
namespace rx
{
typedef void (*MipGenerationFunction)(size_t sourceWidth, size_t sourceHeight, size_t sourceDepth,
const uint8_t *sourceData, size_t sourceRowPitch, size_t sourceDepthPitch,
uint8_t *destData, size_t destRowPitch, size_t destDepthPitch);
typedef void (*LoadImageFunction)(size_t width, size_t height, size_t depth,
const uint8_t *input, size_t inputRowPitch, size_t inputDepthPitch,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
typedef void (*InitializeTextureDataFunction)(size_t width, size_t height, size_t depth,
uint8_t *output, size_t outputRowPitch, size_t outputDepthPitch);
typedef void (*ColorReadFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*ColorWriteFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*ColorCopyFunction)(const uint8_t *source, uint8_t *dest);
typedef void (*VertexCopyFunction)(const uint8_t *input, size_t stride, size_t count, uint8_t *output);
enum VertexConversionType
{
VERTEX_CONVERT_NONE = 0,
VERTEX_CONVERT_CPU = 1,
VERTEX_CONVERT_GPU = 2,
VERTEX_CONVERT_BOTH = 3
};
ColorWriteFunction GetColorWriteFunction(GLenum format, GLenum type);
}
#endif // LIBANGLE_RENDERER_D3D_FORMATUTILSD3D_H_
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#ifndef LIBANGLE_RENDERER_D3D_IMAGEFORMATS_H_ #ifndef LIBANGLE_RENDERER_D3D_IMAGEFORMATS_H_
#define LIBANGLE_RENDERER_D3D_IMAGEFORMATS_H_ #define LIBANGLE_RENDERER_D3D_IMAGEFORMATS_H_
#include "libANGLE/angletypes.h"
#include "common/mathutil.h" #include "common/mathutil.h"
namespace rx namespace rx
......
...@@ -94,7 +94,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level, ...@@ -94,7 +94,7 @@ bool ValidateES2TexImageParameters(Context *context, GLenum target, GLint level,
{ {
if (format != GL_NONE) if (format != GL_NONE)
{ {
if (gl::GetFormatTypeInfo(format, type).internalFormat != texture->getInternalFormat(target, level)) if (gl::GetSizedInternalFormat(format, type) != texture->getInternalFormat(target, level))
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
......
...@@ -731,8 +731,8 @@ static bool IsValidES3CopyTexImageCombination(GLenum textureInternalFormat, GLen ...@@ -731,8 +731,8 @@ static bool IsValidES3CopyTexImageCombination(GLenum textureInternalFormat, GLen
{ {
// Renderbuffers cannot be created with an unsized internal format, so this must be an unsized-format // Renderbuffers cannot be created with an unsized internal format, so this must be an unsized-format
// texture. We can use the same table we use when creating textures to get its effective sized format. // texture. We can use the same table we use when creating textures to get its effective sized format.
const FormatType &typeInfo = GetFormatTypeInfo(framebufferInternalFormatInfo.format, framebufferInternalFormatInfo.type); GLenum sizedInternalFormat = GetSizedInternalFormat(framebufferInternalFormatInfo.format, framebufferInternalFormatInfo.type);
sourceEffectiveFormat = &GetInternalFormatInfo(typeInfo.internalFormat); sourceEffectiveFormat = &GetInternalFormatInfo(sizedInternalFormat);
} }
} }
else else
......
...@@ -151,6 +151,8 @@ ...@@ -151,6 +151,8 @@
'libANGLE/renderer/d3d/DisplayD3D.h', 'libANGLE/renderer/d3d/DisplayD3D.h',
'libANGLE/renderer/d3d/DynamicHLSL.cpp', 'libANGLE/renderer/d3d/DynamicHLSL.cpp',
'libANGLE/renderer/d3d/DynamicHLSL.h', 'libANGLE/renderer/d3d/DynamicHLSL.h',
'libANGLE/renderer/d3d/formatutilsD3D.cpp',
'libANGLE/renderer/d3d/formatutilsD3D.h',
'libANGLE/renderer/d3d/FramebufferD3D.cpp', 'libANGLE/renderer/d3d/FramebufferD3D.cpp',
'libANGLE/renderer/d3d/FramebufferD3D.h', 'libANGLE/renderer/d3d/FramebufferD3D.h',
'libANGLE/renderer/d3d/generatemip.h', 'libANGLE/renderer/d3d/generatemip.h',
......
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