Commit d6cb2443 by Jamie Madill Committed by Shannon Woods

Add a client version parameter to several D3D11-specific texture format queries.

TRAC #23483 Signed-off-by: Geoff Lang Signed-off-by: Shannon Woods Authored-by: Jamie Madill
parent 9e33a112
......@@ -228,7 +228,7 @@ bool Blit11::copyTexture(ID3D11ShaderResourceView *source, const gl::Box &source
// be GL_XXXX_INTEGER but it does not tell us if it is signed or unsigned.
D3D11_SHADER_RESOURCE_VIEW_DESC sourceSRVDesc;
source->GetDesc(&sourceSRVDesc);
GLint sourceInternalFormat = d3d11_gl::GetInternalFormat(sourceSRVDesc.Format);
GLint sourceInternalFormat = d3d11_gl::GetInternalFormat(sourceSRVDesc.Format, mRenderer->getCurrentClientVersion());
BlitParameters parameters = { 0 };
parameters.mDestinationFormat = destFormat;
......@@ -559,7 +559,7 @@ bool Blit11::copyDepthStencil(ID3D11Resource *source, unsigned int sourceSubreso
DXGI_FORMAT format = getTextureFormat(source);
ASSERT(format == getTextureFormat(dest));
unsigned int pixelSize = d3d11::GetFormatPixelBytes(format);
unsigned int pixelSize = d3d11::GetFormatPixelBytes(format, mRenderer->getCurrentClientVersion());
unsigned int copyOffset = 0;
unsigned int copySize = pixelSize;
if (stencilOnly)
......
......@@ -43,13 +43,13 @@ Image11 *Image11::makeImage11(Image *img)
return static_cast<rx::Image11*>(img);
}
void Image11::generateMipmap(Image11 *dest, Image11 *src)
void Image11::generateMipmap(GLuint clientVersion, Image11 *dest, Image11 *src)
{
ASSERT(src->getDXGIFormat() == dest->getDXGIFormat());
ASSERT(src->getWidth() == 1 || src->getWidth() / 2 == dest->getWidth());
ASSERT(src->getHeight() == 1 || src->getHeight() / 2 == dest->getHeight());
MipGenerationFunction mipFunction = d3d11::GetMipGenerationFunction(src->getDXGIFormat());
MipGenerationFunction mipFunction = d3d11::GetMipGenerationFunction(src->getDXGIFormat(), clientVersion);
ASSERT(mipFunction != NULL);
D3D11_MAPPED_SUBRESOURCE destMapped;
......@@ -129,7 +129,7 @@ bool Image11::redefine(Renderer *renderer, GLenum target, GLint internalformat,
// compute the d3d format that will be used
mDXGIFormat = gl_d3d11::GetTexFormat(internalformat, clientVersion);
mActualFormat = d3d11_gl::GetInternalFormat(mDXGIFormat);
mActualFormat = d3d11_gl::GetInternalFormat(mDXGIFormat, clientVersion);
mRenderable = gl_d3d11::GetRTVFormat(internalformat, clientVersion) != DXGI_FORMAT_UNKNOWN;
if (mStagingTexture)
......@@ -161,7 +161,7 @@ void Image11::loadData(GLint xoffset, GLint yoffset, GLint zoffset, GLsizei widt
GLuint clientVersion = mRenderer->getCurrentClientVersion();
GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, type, clientVersion, width, unpackAlignment);
GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, type, clientVersion, width, height, unpackAlignment);
GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat);
GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat, clientVersion);
LoadImageFunction loadFunction = d3d11::GetImageLoadFunction(mInternalFormat, type, clientVersion);
ASSERT(loadFunction != NULL);
......@@ -187,9 +187,9 @@ void Image11::loadCompressedData(GLint xoffset, GLint yoffset, GLint zoffset, GL
GLsizei inputRowPitch = gl::GetRowPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, 1);
GLsizei inputDepthPitch = gl::GetDepthPitch(mInternalFormat, GL_UNSIGNED_BYTE, clientVersion, width, height, 1);
GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat);
GLuint outputBlockWidth = d3d11::GetBlockWidth(mDXGIFormat);
GLuint outputBlockHeight = d3d11::GetBlockHeight(mDXGIFormat);
GLuint outputPixelSize = d3d11::GetFormatPixelBytes(mDXGIFormat, clientVersion);
GLuint outputBlockWidth = d3d11::GetBlockWidth(mDXGIFormat, clientVersion);
GLuint outputBlockHeight = d3d11::GetBlockHeight(mDXGIFormat, clientVersion);
ASSERT(xoffset % outputBlockWidth == 0);
ASSERT(yoffset % outputBlockHeight == 0);
......@@ -329,7 +329,7 @@ void Image11::createStagingTexture()
GLsizei height = mHeight;
// adjust size if needed for compressed textures
d3d11::MakeValidSize(false, dxgiFormat, &width, &height, &lodOffset);
d3d11::MakeValidSize(false, dxgiFormat, mRenderer->getCurrentClientVersion(), &width, &height, &lodOffset);
if (mTarget == GL_TEXTURE_3D)
{
......
......@@ -34,7 +34,7 @@ class Image11 : public Image
static Image11 *makeImage11(Image *img);
static void generateMipmap(Image11 *dest, Image11 *src);
static void generateMipmap(GLuint clientVersion, Image11 *dest, Image11 *src);
virtual bool isDirty() const;
......
......@@ -202,8 +202,8 @@ RenderTarget11::RenderTarget11(Renderer *renderer, ID3D11RenderTargetView *rtv,
mDepth = depth;
mSamples = samples;
mInternalFormat = d3d11_gl::GetInternalFormat(desc.Format);
mActualFormat = d3d11_gl::GetInternalFormat(desc.Format);
mInternalFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer->getCurrentClientVersion());
mActualFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer->getCurrentClientVersion());
}
}
......@@ -231,8 +231,8 @@ RenderTarget11::RenderTarget11(Renderer *renderer, ID3D11DepthStencilView *dsv,
mDepth = depth;
mSamples = samples;
mInternalFormat = d3d11_gl::GetInternalFormat(desc.Format);
mActualFormat = d3d11_gl::GetInternalFormat(desc.Format);
mInternalFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer->getCurrentClientVersion());
mActualFormat = d3d11_gl::GetInternalFormat(desc.Format, renderer->getCurrentClientVersion());
}
}
......@@ -351,7 +351,7 @@ RenderTarget11::RenderTarget11(Renderer *renderer, GLsizei width, GLsizei height
mDepth = 1;
mInternalFormat = internalFormat;
mSamples = supportedSamples;
mActualFormat = d3d11_gl::GetInternalFormat(texFormat);
mActualFormat = d3d11_gl::GetInternalFormat(texFormat, renderer->getCurrentClientVersion());
mSubresourceIndex = D3D11CalcSubresource(0, 0, 1);
}
......
......@@ -434,9 +434,13 @@ int Renderer11::generateConfigs(ConfigDesc **configDescList)
if (depthStencilFormatOK)
{
// FIXME: parse types from context version
ASSERT(d3d11_gl::GetInternalFormat(renderTargetFormat, 2) == d3d11_gl::GetInternalFormat(renderTargetFormat, 3));
ASSERT(d3d11_gl::GetInternalFormat(depthStencilFormat, 2) == d3d11_gl::GetInternalFormat(depthStencilFormat, 3));
ConfigDesc newConfig;
newConfig.renderTargetFormat = d3d11_gl::GetInternalFormat(renderTargetFormat);
newConfig.depthStencilFormat = d3d11_gl::GetInternalFormat(depthStencilFormat);
newConfig.renderTargetFormat = d3d11_gl::GetInternalFormat(renderTargetFormat, getCurrentClientVersion());
newConfig.depthStencilFormat = d3d11_gl::GetInternalFormat(depthStencilFormat, getCurrentClientVersion());
newConfig.multiSample = 0; // FIXME: enumerate multi-sampling
newConfig.fastConfig = true; // Assume all DX11 format conversions to be fast
newConfig.es3Capable = true;
......@@ -3167,7 +3171,7 @@ void Renderer11::generateMipmap(Image *dest, Image *src)
{
Image11 *dest11 = Image11::makeImage11(dest);
Image11 *src11 = Image11::makeImage11(src);
Image11::generateMipmap(dest11, src11);
Image11::generateMipmap(getCurrentClientVersion(), dest11, src11);
}
TextureStorage *Renderer11::createTextureStorage2D(SwapChain *swapChain)
......@@ -3288,7 +3292,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
GLuint clientVersion = getCurrentClientVersion();
GLint sourceInternalFormat = d3d11_gl::GetInternalFormat(textureDesc.Format);
GLint sourceInternalFormat = d3d11_gl::GetInternalFormat(textureDesc.Format, clientVersion);
GLenum sourceFormat = gl::GetFormat(sourceInternalFormat, clientVersion);
GLenum sourceType = gl::GetType(sourceInternalFormat, clientVersion);
......@@ -3325,7 +3329,7 @@ void Renderer11::readTextureData(ID3D11Texture2D *texture, unsigned int subResou
}
else
{
ColorReadFunction readFunc = d3d11::GetColorReadFunction(textureDesc.Format);
ColorReadFunction readFunc = d3d11::GetColorReadFunction(textureDesc.Format, clientVersion);
ColorWriteFunction writeFunc = gl::GetColorWriteFunction(format, type, clientVersion);
unsigned char temp[16]; // Maximum size of any Color<T> type used.
......
......@@ -115,11 +115,13 @@ bool TextureStorage11::updateSubresourceLevel(ID3D11Resource *srcTexture, unsign
{
if (srcTexture)
{
GLuint clientVersion = mRenderer->getCurrentClientVersion();
D3D11_BOX srcBox;
srcBox.left = xoffset;
srcBox.top = yoffset;
srcBox.right = xoffset + roundUp((unsigned int)width, d3d11::GetBlockWidth(mTextureFormat));
srcBox.bottom = yoffset + roundUp((unsigned int)height, d3d11::GetBlockHeight(mTextureFormat));
srcBox.right = xoffset + roundUp((unsigned int)width, d3d11::GetBlockWidth(mTextureFormat, clientVersion));
srcBox.bottom = yoffset + roundUp((unsigned int)height, d3d11::GetBlockHeight(mTextureFormat, clientVersion));
srcBox.front = zoffset;
srcBox.back = zoffset + depth;
......@@ -214,7 +216,7 @@ TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, int levels, GLenum
if (width > 0 && height > 0)
{
// adjust size if needed for compressed textures
d3d11::MakeValidSize(false, mTextureFormat, &width, &height, &mLodOffset);
d3d11::MakeValidSize(false, mTextureFormat, clientVersion, &width, &height, &mLodOffset);
ID3D11Device *device = mRenderer->getDevice();
......@@ -436,7 +438,7 @@ TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, int levels, GLe
{
// adjust size if needed for compressed textures
int height = size;
d3d11::MakeValidSize(false, mTextureFormat, &size, &height, &mLodOffset);
d3d11::MakeValidSize(false, mTextureFormat, clientVersion, &size, &height, &mLodOffset);
ID3D11Device *device = mRenderer->getDevice();
......@@ -659,7 +661,7 @@ TextureStorage11_3D::TextureStorage11_3D(Renderer *renderer, int levels, GLenum
if (width > 0 && height > 0 && depth > 0)
{
// adjust size if needed for compressed textures
d3d11::MakeValidSize(false, mTextureFormat, &width, &height, &mLodOffset);
d3d11::MakeValidSize(false, mTextureFormat, clientVersion, &width, &height, &mLodOffset);
ID3D11Device *device = mRenderer->getDevice();
......@@ -909,7 +911,7 @@ TextureStorage11_2DArray::TextureStorage11_2DArray(Renderer *renderer, int level
if (width > 0 && height > 0 && depth > 0)
{
// adjust size if needed for compressed textures
d3d11::MakeValidSize(false, mTextureFormat, &width, &height, &mLodOffset);
d3d11::MakeValidSize(false, mTextureFormat, clientVersion, &width, &height, &mLodOffset);
ID3D11Device *device = mRenderer->getDevice();
......
......@@ -534,7 +534,7 @@ static const DXGIFormatInfoMap &GetDXGIFormatInfoMap()
return infoMap;
}
static bool GetDXGIFormatInfo(DXGI_FORMAT format, DXGIFormatInfo *outFormatInfo)
static bool GetDXGIFormatInfo(DXGI_FORMAT format, GLuint clientVersion, DXGIFormatInfo *outFormatInfo)
{
const DXGIFormatInfoMap &infoMap = GetDXGIFormatInfoMap();
DXGIFormatInfoMap::const_iterator iter = infoMap.find(format);
......@@ -662,10 +662,10 @@ bool GetDepthStencilInfo(DXGI_FORMAT format, DXGIDepthStencilInfo *outDepthStenc
namespace d3d11
{
MipGenerationFunction GetMipGenerationFunction(DXGI_FORMAT format)
MipGenerationFunction GetMipGenerationFunction(DXGI_FORMAT format, GLuint clientVersion)
{
DXGIFormatInfo formatInfo;
if (GetDXGIFormatInfo(format, &formatInfo))
if (GetDXGIFormatInfo(format, clientVersion, &formatInfo))
{
return formatInfo.mMipGenerationFunction;
}
......@@ -712,10 +712,10 @@ LoadImageFunction GetImageLoadFunction(GLint internalFormat, GLenum type, GLuint
}
}
GLuint GetFormatPixelBytes(DXGI_FORMAT format)
GLuint GetFormatPixelBytes(DXGI_FORMAT format, GLuint clientVersion)
{
DXGIFormatInfo dxgiFormatInfo;
if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
if (GetDXGIFormatInfo(format, clientVersion, &dxgiFormatInfo))
{
return dxgiFormatInfo.mPixelBits / 8;
}
......@@ -726,10 +726,10 @@ GLuint GetFormatPixelBytes(DXGI_FORMAT format)
}
}
GLuint GetBlockWidth(DXGI_FORMAT format)
GLuint GetBlockWidth(DXGI_FORMAT format, GLuint clientVersion)
{
DXGIFormatInfo dxgiFormatInfo;
if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
if (GetDXGIFormatInfo(format, clientVersion, &dxgiFormatInfo))
{
return dxgiFormatInfo.mBlockWidth;
}
......@@ -740,10 +740,10 @@ GLuint GetBlockWidth(DXGI_FORMAT format)
}
}
GLuint GetBlockHeight(DXGI_FORMAT format)
GLuint GetBlockHeight(DXGI_FORMAT format, GLuint clientVersion)
{
DXGIFormatInfo dxgiFormatInfo;
if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
if (GetDXGIFormatInfo(format, clientVersion, &dxgiFormatInfo))
{
return dxgiFormatInfo.mBlockHeight;
}
......@@ -814,10 +814,10 @@ GLuint GetStencilOffset(DXGI_FORMAT format)
}
}
void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset)
void MakeValidSize(bool isImage, DXGI_FORMAT format, GLuint clientVersion, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset)
{
DXGIFormatInfo dxgiFormatInfo;
if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
if (GetDXGIFormatInfo(format, clientVersion, &dxgiFormatInfo))
{
int upsampleCount = 0;
......@@ -848,10 +848,10 @@ const DXGIFormatSet &GetAllUsedDXGIFormats()
return formatSet;
}
ColorReadFunction GetColorReadFunction(DXGI_FORMAT format)
ColorReadFunction GetColorReadFunction(DXGI_FORMAT format, GLuint clientVersion)
{
DXGIFormatInfo dxgiFormatInfo;
if (GetDXGIFormatInfo(format, &dxgiFormatInfo))
if (GetDXGIFormatInfo(format, clientVersion, &dxgiFormatInfo))
{
return dxgiFormatInfo.mColorReadFunction;
}
......@@ -1030,10 +1030,10 @@ DXGI_FORMAT GetRenderableFormat(GLint internalFormat, GLuint clientVersion)
namespace d3d11_gl
{
GLint GetInternalFormat(DXGI_FORMAT format)
GLint GetInternalFormat(DXGI_FORMAT format, GLuint clientVersion)
{
DXGIFormatInfo formatInfo;
if (GetDXGIFormatInfo(format, &formatInfo))
if (GetDXGIFormatInfo(format, clientVersion, &formatInfo))
{
return formatInfo.mInternalFormat;
}
......
......@@ -20,23 +20,23 @@ namespace d3d11
typedef std::set<DXGI_FORMAT> DXGIFormatSet;
MipGenerationFunction GetMipGenerationFunction(DXGI_FORMAT format);
MipGenerationFunction GetMipGenerationFunction(DXGI_FORMAT format, GLuint clientVersion);
LoadImageFunction GetImageLoadFunction(GLint internalFormat, GLenum type, GLuint clientVersion);
GLuint GetFormatPixelBytes(DXGI_FORMAT format);
GLuint GetBlockWidth(DXGI_FORMAT format);
GLuint GetBlockHeight(DXGI_FORMAT format);
GLuint GetFormatPixelBytes(DXGI_FORMAT format, GLuint clientVersion);
GLuint GetBlockWidth(DXGI_FORMAT format, GLuint clientVersion);
GLuint GetBlockHeight(DXGI_FORMAT format, GLuint clientVersion);
GLuint GetDepthBits(DXGI_FORMAT format);
GLuint GetDepthOffset(DXGI_FORMAT format);
GLuint GetStencilBits(DXGI_FORMAT format);
GLuint GetStencilOffset(DXGI_FORMAT format);
void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
void MakeValidSize(bool isImage, DXGI_FORMAT format, GLuint clientVersion, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset);
const DXGIFormatSet &GetAllUsedDXGIFormats();
ColorReadFunction GetColorReadFunction(DXGI_FORMAT format);
ColorReadFunction GetColorReadFunction(DXGI_FORMAT format, GLuint clientVersion);
ColorCopyFunction GetFastCopyFunction(DXGI_FORMAT sourceFormat, GLenum destFormat, GLenum destType, GLuint clientVersion);
}
......@@ -55,7 +55,7 @@ DXGI_FORMAT GetRenderableFormat(GLint internalFormat, GLuint clientVersion);
namespace d3d11_gl
{
GLint GetInternalFormat(DXGI_FORMAT format);
GLint GetInternalFormat(DXGI_FORMAT format, GLuint clientVersion);
}
......
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