Commit 9eeecfc2 by Jamie Madill

Split DXGI format info to a GL mapping and info block.

The GL mapping depends on context client version (for certain depth textures), but the DXGI base format info is consistent across versions. Also add DXGI component type information to the table, and add a few missing formats related to vertex inputs. Change-Id: I2d1a8ca92b1cb39f4592d94d7d435ae0ada1de65 Reviewed-on: https://chromium-review.googlesource.com/183583Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 6246dc8f
...@@ -766,7 +766,7 @@ bool Blit11::copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubreso ...@@ -766,7 +766,7 @@ bool Blit11::copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubreso
DXGI_FORMAT format = GetTextureFormat(source); DXGI_FORMAT format = GetTextureFormat(source);
ASSERT(format == GetTextureFormat(dest)); ASSERT(format == GetTextureFormat(dest));
unsigned int pixelSize = d3d11::GetFormatPixelBytes(format, mRenderer->getCurrentClientVersion()); unsigned int pixelSize = d3d11::GetFormatPixelBytes(format);
unsigned int copyOffset = 0; unsigned int copyOffset = 0;
unsigned int copySize = pixelSize; unsigned int copySize = pixelSize;
if (stencilOnly) if (stencilOnly)
......
...@@ -294,7 +294,7 @@ ID3D11ShaderResourceView *BufferStorage11::getSRV(DXGI_FORMAT srvFormat) ...@@ -294,7 +294,7 @@ ID3D11ShaderResourceView *BufferStorage11::getSRV(DXGI_FORMAT srvFormat)
D3D11_SHADER_RESOURCE_VIEW_DESC bufferSRVDesc; D3D11_SHADER_RESOURCE_VIEW_DESC bufferSRVDesc;
bufferSRVDesc.Buffer.ElementOffset = 0; bufferSRVDesc.Buffer.ElementOffset = 0;
bufferSRVDesc.Buffer.ElementWidth = mSize / d3d11::GetFormatPixelBytes(srvFormat, mRenderer->getCurrentClientVersion()); bufferSRVDesc.Buffer.ElementWidth = mSize / d3d11::GetFormatPixelBytes(srvFormat);
bufferSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER; bufferSRVDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
bufferSRVDesc.Format = srvFormat; bufferSRVDesc.Format = srvFormat;
......
...@@ -46,7 +46,7 @@ void Image11::generateMipmap(GLuint clientVersion, Image11 *dest, Image11 *src) ...@@ -46,7 +46,7 @@ void Image11::generateMipmap(GLuint clientVersion, Image11 *dest, Image11 *src)
ASSERT(src->getWidth() == 1 || src->getWidth() / 2 == dest->getWidth()); ASSERT(src->getWidth() == 1 || src->getWidth() / 2 == dest->getWidth());
ASSERT(src->getHeight() == 1 || src->getHeight() / 2 == dest->getHeight()); ASSERT(src->getHeight() == 1 || src->getHeight() / 2 == dest->getHeight());
MipGenerationFunction mipFunction = d3d11::GetMipGenerationFunction(src->getDXGIFormat(), clientVersion); MipGenerationFunction mipFunction = d3d11::GetMipGenerationFunction(src->getDXGIFormat());
ASSERT(mipFunction != NULL); ASSERT(mipFunction != NULL);
D3D11_MAPPED_SUBRESOURCE destMapped; D3D11_MAPPED_SUBRESOURCE destMapped;
...@@ -157,7 +157,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt ...@@ -157,7 +157,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt
GLuint clientVersion = mRenderer->getCurrentClientVersion(); GLuint clientVersion = mRenderer->getCurrentClientVersion();
GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, clientVersion, width, unpackAlignment); GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, clientVersion, width, unpackAlignment);
GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, type, clientVersion, width, height, unpackAlignment); GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, type, clientVersion, width, height, unpackAlignment);
GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat, clientVersion); GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat);
LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, type, clientVersion); LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, type, clientVersion);
ASSERT(loadFunction != NULL); ASSERT(loadFunction != NULL);
...@@ -183,9 +183,9 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GL ...@@ -183,9 +183,9 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GL
GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, 1); GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, 1);
GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, height, 1); GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, height, 1);
GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat, clientVersion); GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat);
GLuint outputBlockWidth = d3d11::GetBlockWidth(mDXGIFormat, clientVersion); GLuint outputBlockWidth = d3d11::GetBlockWidth(mDXGIFormat);
GLuint outputBlockHeight = d3d11::GetBlockHeight(mDXGIFormat, clientVersion); GLuint outputBlockHeight = d3d11::GetBlockHeight(mDXGIFormat);
ASSERT(xoffset % outputBlockWidth == 0); ASSERT(xoffset % outputBlockWidth == 0);
ASSERT(yoffset % outputBlockHeight == 0); ASSERT(yoffset % outputBlockHeight == 0);
...@@ -326,7 +326,7 @@ void Image11::createStagingTexture() ...@@ -326,7 +326,7 @@ void Image11::createStagingTexture()
GLsizei height = mHeight; GLsizei height = mHeight;
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
d3d11::MakeValidSize(false, dxgiFormat, mRenderer->getCurrentClientVersion(), &width, &height, &lodOffset); d3d11::MakeValidSize(false, dxgiFormat, &width, &height, &lodOffset);
if (mTarget == GL_TEXTURE_3D) if (mTarget == GL_TEXTURE_3D)
{ {
......
...@@ -3188,7 +3188,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou ...@@ -3188,7 +3188,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
GLenum destInternalFormat = gl::GetSizedInternalFormat(format, type, clientVersion); GLenum destInternalFormat = gl::GetSizedInternalFormat(format, type, clientVersion);
GLuint destPixelSize = gl::GetPixelBytes(destInternalFormat, clientVersion); GLuint destPixelSize = gl::GetPixelBytes(destInternalFormat, clientVersion);
ColorCopyFunction fastCopyFunc = d3d11::GetFastCopyFunction(textureDesc.Format, format, type, getCurrentClientVersion()); ColorCopyFunction fastCopyFunc = d3d11::GetFastCopyFunction(textureDesc.Format, format, type);
if (fastCopyFunc) if (fastCopyFunc)
{ {
// Fast copy is possible through some special function // Fast copy is possible through some special function
...@@ -3205,7 +3205,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou ...@@ -3205,7 +3205,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
} }
else else
{ {
ColorReadFunction readFunc = d3d11::GetColorReadFunction(textureDesc.Format, clientVersion); ColorReadFunction readFunc = d3d11::GetColorReadFunction(textureDesc.Format);
ColorWriteFunction writeFunc = gl::GetColorWriteFunction(format, type, clientVersion); ColorWriteFunction writeFunc = gl::GetColorWriteFunction(format, type, clientVersion);
unsigned char temp[16]; // Maximum size of any Color<T> type used. unsigned char temp[16]; // Maximum size of any Color<T> type used.
......
...@@ -205,8 +205,6 @@ bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsign ...@@ -205,8 +205,6 @@ bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsign
{ {
invalidateSwizzleCacheLevel(level); invalidateSwizzleCacheLevel(level);
GLuint clientVersion = mRenderer->getCurrentClientVersion();
gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level)); gl::Extents texSize(getLevelWidth(level), getLevelHeight(level), getLevelDepth(level));
gl::Box copyArea(xoffset, yoffset, zoffset, width, height, depth); gl::Box copyArea(xoffset, yoffset, zoffset, width, height, depth);
...@@ -236,8 +234,8 @@ bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsign ...@@ -236,8 +234,8 @@ bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsign
D3D11_BOX srcBox; D3D11_BOX srcBox;
srcBox.left = copyArea.x; srcBox.left = copyArea.x;
srcBox.top = copyArea.y; srcBox.top = copyArea.y;
srcBox.right = copyArea.x + roundUp((unsigned int)width, d3d11::GetBlockWidth(mTextureFormat, clientVersion)); srcBox.right = copyArea.x + roundUp((unsigned int)width, d3d11::GetBlockWidth(mTextureFormat));
srcBox.bottom = copyArea.y + roundUp((unsigned int)height, d3d11::GetBlockHeight(mTextureFormat, clientVersion)); srcBox.bottom = copyArea.y + roundUp((unsigned int)height, d3d11::GetBlockHeight(mTextureFormat));
srcBox.front = copyArea.z; srcBox.front = copyArea.z;
srcBox.back = copyArea.z + copyArea.depth; srcBox.back = copyArea.z + copyArea.depth;
...@@ -357,7 +355,7 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, int baseLevel, int ...@@ -357,7 +355,7 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, int baseLevel, int
if (width > 0 && height > 0) if (width > 0 && height > 0)
{ {
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
d3d11::MakeValidSize(false, mTextureFormat, clientVersion, &width, &height, &mLodOffset); d3d11::MakeValidSize(false, mTextureFormat, &width, &height, &mLodOffset);
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
...@@ -674,7 +672,7 @@ TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, int baseLevel, ...@@ -674,7 +672,7 @@ TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, int baseLevel,
{ {
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
int height = size; int height = size;
d3d11::MakeValidSize(false, mTextureFormat, clientVersion, &size, &height, &mLodOffset); d3d11::MakeValidSize(false, mTextureFormat, &size, &height, &mLodOffset);
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
...@@ -1009,7 +1007,7 @@ TextureStorage11_3D::TextureStorage11_3D(Renderer *renderer, int baseLevel, int ...@@ -1009,7 +1007,7 @@ TextureStorage11_3D::TextureStorage11_3D(Renderer *renderer, int baseLevel, int
if (width > 0 && height > 0 && depth > 0) if (width > 0 && height > 0 && depth > 0)
{ {
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
d3d11::MakeValidSize(false, mTextureFormat, clientVersion, &width, &height, &mLodOffset); d3d11::MakeValidSize(false, mTextureFormat, &width, &height, &mLodOffset);
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
...@@ -1358,7 +1356,7 @@ TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer *renderer, int baseL ...@@ -1358,7 +1356,7 @@ TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer *renderer, int baseL
if (width > 0 && height > 0 && depth > 0) if (width > 0 && height > 0 && depth > 0)
{ {
// adjust size if needed for compressed textures // adjust size if needed for compressed textures
d3d11::MakeValidSize(false, mTextureFormat, clientVersion, &width, &height, &mLodOffset); d3d11::MakeValidSize(false, mTextureFormat, &width, &height, &mLodOffset);
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
......
...@@ -22,24 +22,24 @@ namespace d3d11 ...@@ -22,24 +22,24 @@ namespace d3d11
typedef std::set<DXGI_FORMAT> DXGIFormatSet; typedef std::set<DXGI_FORMAT> DXGIFormatSet;
MipGenerationFunction GetMipGenerationFunction(DXGI_FORMAT format, GLuint clientVersion); MipGenerationFunction GetMipGenerationFunction(DXGI_FORMAT format);
LoadImageFunction GetImageLoadFunction(GLenum internalFormat, GLenum type, GLuint clientVersion); LoadImageFunction GetImageLoadFunction(GLenum internalFormat, GLenum type, GLuint clientVersion);
GLuint GetFormatPixelBytes(DXGI_FORMAT format, GLuint clientVersion); GLuint GetFormatPixelBytes(DXGI_FORMAT format);
GLuint GetBlockWidth(DXGI_FORMAT format, GLuint clientVersion); GLuint GetBlockWidth(DXGI_FORMAT format);
GLuint GetBlockHeight(DXGI_FORMAT format, GLuint clientVersion); GLuint GetBlockHeight(DXGI_FORMAT format);
GLuint GetDepthBits(DXGI_FORMAT format); GLuint GetDepthBits(DXGI_FORMAT format);
GLuint GetDepthOffset(DXGI_FORMAT format); GLuint GetDepthOffset(DXGI_FORMAT format);
GLuint GetStencilBits(DXGI_FORMAT format); GLuint GetStencilBits(DXGI_FORMAT format);
GLuint GetStencilOffset(DXGI_FORMAT format); GLuint GetStencilOffset(DXGI_FORMAT format);
void MakeValidSize(bool isImage, DXGI_FORMAT format, GLuint clientVersion, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset); void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
const DXGIFormatSet &GetAllUsedDXGIFormats(); const DXGIFormatSet &GetAllUsedDXGIFormats();
ColorReadFunction GetColorReadFunction(DXGI_FORMAT format, GLuint clientVersion); ColorReadFunction GetColorReadFunction(DXGI_FORMAT format);
ColorCopyFunction GetFastCopyFunction(DXGI_FORMAT sourceFormat, GLenum destFormat, GLenum destType, GLuint clientVersion); ColorCopyFunction GetFastCopyFunction(DXGI_FORMAT sourceFormat, GLenum destFormat, GLenum destType);
} }
......
...@@ -234,7 +234,7 @@ void GenerateInitialTextureData(GLint internalFormat, GLuint clientVersion, GLui ...@@ -234,7 +234,7 @@ void GenerateInitialTextureData(GLint internalFormat, GLuint clientVersion, GLui
unsigned int mipHeight = std::max(height >> i, 1U); unsigned int mipHeight = std::max(height >> i, 1U);
unsigned int mipDepth = std::max(depth >> i, 1U); unsigned int mipDepth = std::max(depth >> i, 1U);
unsigned int rowWidth = d3d11::GetFormatPixelBytes(dxgiFormat, clientVersion) * mipWidth; unsigned int rowWidth = d3d11::GetFormatPixelBytes(dxgiFormat) * mipWidth;
unsigned int imageSize = rowWidth * height; unsigned int imageSize = rowWidth * height;
outData->at(i).resize(rowWidth * mipHeight * mipDepth); outData->at(i).resize(rowWidth * mipHeight * mipDepth);
......
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