Commit c5b2ba53 by Geoff Lang

Revert "Avoid a copy in TextureStorage11::setData"

Speculative fix for performance regression. BUG=532647 This reverts commit 9cf9bcbe. Change-Id: I53e41f6c17f89c400e38bfcdf3147946c27906c0 Reviewed-on: https://chromium-review.googlesource.com/300540Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent e5f735f9
...@@ -252,7 +252,7 @@ gl::Error Image11::loadData(const gl::Box &area, const gl::PixelUnpackState &unp ...@@ -252,7 +252,7 @@ gl::Error Image11::loadData(const gl::Box &area, const gl::PixelUnpackState &unp
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes; GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, mRenderer->getRenderer11DeviceCaps()); const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(type).loadFunction; LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(type);
D3D11_MAPPED_SUBRESOURCE mappedImage; D3D11_MAPPED_SUBRESOURCE mappedImage;
gl::Error error = map(D3D11_MAP_WRITE, &mappedImage); gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
...@@ -286,7 +286,7 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input) ...@@ -286,7 +286,7 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
ASSERT(area.y % outputBlockHeight == 0); ASSERT(area.y % outputBlockHeight == 0);
const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, mRenderer->getRenderer11DeviceCaps()); const d3d11::TextureFormat &d3dFormatInfo = d3d11::GetTextureFormatInfo(mInternalFormat, mRenderer->getRenderer11DeviceCaps());
LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(GL_UNSIGNED_BYTE).loadFunction; LoadImageFunction loadFunction = d3dFormatInfo.loadFunctions.at(GL_UNSIGNED_BYTE);
D3D11_MAPPED_SUBRESOURCE mappedImage; D3D11_MAPPED_SUBRESOURCE mappedImage;
gl::Error error = map(D3D11_MAP_WRITE, &mappedImage); gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
......
...@@ -657,29 +657,19 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ImageD3D *image ...@@ -657,29 +657,19 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ImageD3D *image
UINT bufferDepthPitch = bufferRowPitch * height; UINT bufferDepthPitch = bufferRowPitch * height;
size_t neededSize = bufferDepthPitch * depth; size_t neededSize = bufferDepthPitch * depth;
MemoryBuffer *conversionBuffer = nullptr; MemoryBuffer *conversionBuffer = NULL;
const uint8_t *data = nullptr; error = mRenderer->getScratchMemoryBuffer(neededSize, &conversionBuffer);
if (error.isError())
d3d11::LoadImageFunctionInfo loadFunctionInfo = d3d11Format.loadFunctions.at(type);
if (loadFunctionInfo.requiresConversion)
{
error = mRenderer->getScratchMemoryBuffer(neededSize, &conversionBuffer);
if (error.isError())
{
return error;
}
loadFunctionInfo.loadFunction(width, height, depth, pixelData, srcRowPitch, srcDepthPitch,
conversionBuffer->data(), bufferRowPitch, bufferDepthPitch);
data = conversionBuffer->data();
}
else
{ {
data = pixelData; return error;
bufferRowPitch = srcRowPitch;
bufferDepthPitch = srcDepthPitch;
} }
// TODO: fast path
LoadImageFunction loadFunction = d3d11Format.loadFunctions.at(type);
loadFunction(width, height, depth,
pixelData, srcRowPitch, srcDepthPitch,
conversionBuffer->data(), bufferRowPitch, bufferDepthPitch);
ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext(); ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
if (!fullUpdate) if (!fullUpdate)
...@@ -694,13 +684,15 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ImageD3D *image ...@@ -694,13 +684,15 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ImageD3D *image
destD3DBox.front = destBox->z; destD3DBox.front = destBox->z;
destD3DBox.back = destBox->z + destBox->depth; destD3DBox.back = destBox->z + destBox->depth;
immediateContext->UpdateSubresource(resource, destSubresource, &destD3DBox, data, immediateContext->UpdateSubresource(resource, destSubresource,
&destD3DBox, conversionBuffer->data(),
bufferRowPitch, bufferDepthPitch); bufferRowPitch, bufferDepthPitch);
} }
else else
{ {
immediateContext->UpdateSubresource(resource, destSubresource, NULL, data, bufferRowPitch, immediateContext->UpdateSubresource(resource, destSubresource,
bufferDepthPitch); NULL, conversionBuffer->data(),
bufferRowPitch, bufferDepthPitch);
} }
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
......
...@@ -60,17 +60,6 @@ struct DXGIFormat ...@@ -60,17 +60,6 @@ struct DXGIFormat
}; };
const DXGIFormat &GetDXGIFormatInfo(DXGI_FORMAT format); const DXGIFormat &GetDXGIFormatInfo(DXGI_FORMAT format);
struct LoadImageFunctionInfo
{
LoadImageFunctionInfo(LoadImageFunction loadFunction, bool requiresConversion)
: loadFunction(loadFunction), requiresConversion(requiresConversion)
{
}
LoadImageFunction loadFunction;
bool requiresConversion;
};
struct TextureFormat struct TextureFormat
{ {
TextureFormat(); TextureFormat();
...@@ -87,7 +76,7 @@ struct TextureFormat ...@@ -87,7 +76,7 @@ struct TextureFormat
InitializeTextureDataFunction dataInitializerFunction; InitializeTextureDataFunction dataInitializerFunction;
typedef std::map<GLenum, LoadImageFunctionInfo> LoadFunctionMap; typedef std::map<GLenum, LoadImageFunction> LoadFunctionMap;
LoadFunctionMap loadFunctions; LoadFunctionMap loadFunctions;
}; };
const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, const Renderer11DeviceCaps &renderer11DeviceCaps); const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, const Renderer11DeviceCaps &renderer11DeviceCaps);
......
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