Commit 3a913264 by Jamie Madill

Revert "Avoid a copy in TextureStorage11::setData"

Fails on the Windows builders: https://build.chromium.org/p/chromium.gpu.fyi/builders/GPU%20Win%20Builder/builds/42201 e:\b\build\slave\gpu_win_builder\build\src\third_party\angle\src\libangle\renderer\d3d\d3d11\load_functions_table_autogen.cpp(787) : error C2440: 'return' : cannot convert from 'const std::map<GLenum,rx::LoadImageFunction,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>' to 'const std::map<GLenum,rx::d3d11::LoadImageFunctionInfo,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>> &' with [ _Kty=GLuint , _Ty=rx::LoadImageFunction ] and [ _Kty=GLuint , _Ty=rx::d3d11::LoadImageFunctionInfo ] Reason: cannot convert from 'const std::map<GLenum,rx::LoadImageFunction,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>' to 'const std::map<GLenum,rx::d3d11::LoadImageFunctionInfo,std::less<_Kty>,std::allocator<std::pair<const _Kty,_Ty>>>' with [ _Kty=GLuint , _Ty=rx::LoadImageFunction ] and [ _Kty=GLuint , _Ty=rx::d3d11::LoadImageFunctionInfo ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called This reverts commit 52d3e43b. Change-Id: I83774ea09ccbb2b92ff609714e1c7201beb775bc Reviewed-on: https://chromium-review.googlesource.com/326540Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent b0c14b79
......@@ -256,7 +256,7 @@ gl::Error Image11::loadData(const gl::Box &area, const gl::PixelUnpackState &unp
GLuint outputPixelSize = dxgiFormatInfo.pixelBytes;
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;
gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
......@@ -291,7 +291,7 @@ gl::Error Image11::loadCompressedData(const gl::Box &area, const void *input)
ASSERT(area.y % outputBlockHeight == 0);
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;
gl::Error error = map(D3D11_MAP_WRITE, &mappedImage);
......
......@@ -664,30 +664,18 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ImageD3D *image
UINT bufferDepthPitch = bufferRowPitch * height;
size_t neededSize = bufferDepthPitch * depth;
MemoryBuffer *conversionBuffer = nullptr;
const uint8_t *data = nullptr;
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 + srcSkipBytes, srcRowPitch,
srcDepthPitch, conversionBuffer->data(), bufferRowPitch,
bufferDepthPitch);
data = conversionBuffer->data();
}
else
MemoryBuffer *conversionBuffer = NULL;
error = mRenderer->getScratchMemoryBuffer(neededSize, &conversionBuffer);
if (error.isError())
{
data = pixelData + srcSkipBytes;
bufferRowPitch = srcRowPitch;
bufferDepthPitch = srcDepthPitch;
return error;
}
// TODO: fast path
LoadImageFunction loadFunction = d3d11Format.loadFunctions.at(type);
loadFunction(width, height, depth, pixelData + srcSkipBytes, srcRowPitch, srcDepthPitch,
conversionBuffer->data(), bufferRowPitch, bufferDepthPitch);
ID3D11DeviceContext *immediateContext = mRenderer->getDeviceContext();
if (!fullUpdate)
......@@ -702,13 +690,15 @@ gl::Error TextureStorage11::setData(const gl::ImageIndex &index, ImageD3D *image
destD3DBox.front = destBox->z;
destD3DBox.back = destBox->z + destBox->depth;
immediateContext->UpdateSubresource(resource, destSubresource, &destD3DBox, data,
immediateContext->UpdateSubresource(resource, destSubresource,
&destD3DBox, conversionBuffer->data(),
bufferRowPitch, bufferDepthPitch);
}
else
{
immediateContext->UpdateSubresource(resource, destSubresource, NULL, data, bufferRowPitch,
bufferDepthPitch);
immediateContext->UpdateSubresource(resource, destSubresource,
NULL, conversionBuffer->data(),
bufferRowPitch, bufferDepthPitch);
}
return gl::Error(GL_NO_ERROR);
......
......@@ -22,7 +22,6 @@ template = """// GENERATED FILE - DO NOT EDIT.
#include "libANGLE/renderer/d3d/d3d11/load_functions_table.h"
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
#include "libANGLE/renderer/d3d/loadimage.h"
#include "libANGLE/renderer/d3d/loadimage_etc.h"
......@@ -71,8 +70,8 @@ void UnreachableLoadFunction(size_t width,
}} // namespace
// TODO we can replace these maps with more generated code
const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum {internal_format},
DXGI_FORMAT {dxgi_format})
const std::map<GLenum, LoadImageFunction> &GetLoadFunctionsMap(GLenum {internal_format},
DXGI_FORMAT {dxgi_format})
{{
// clang-format off
switch ({internal_format})
......@@ -80,7 +79,7 @@ const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum {inter
{data}
default:
{{
static std::map<GLenum, LoadImageFunctionInfo> emptyLoadFunctionsMap;
static std::map<GLenum, LoadImageFunction> emptyLoadFunctionsMap;
return emptyLoadFunctionsMap;
}}
}}
......@@ -97,8 +96,8 @@ internal_format_param = 'internalFormat'
dxgi_format_param = 'dxgiFormat'
dxgi_format_unknown = "DXGI_FORMAT_UNKNOWN"
def get_function_maps_string(typestr, function, requiresConversion):
return ' loadMap[' + typestr + '] = LoadImageFunctionInfo(' + function + ', ' + requiresConversion + ');\n'
def get_function_maps_string(typestr, function):
return ' loadMap[' + typestr + '] = ' + function + ';\n'
def get_unknown_format_string(dxgi_to_type_map, dxgi_unknown_string):
if dxgi_unknown_string not in dxgi_to_type_map:
......@@ -107,7 +106,7 @@ def get_unknown_format_string(dxgi_to_type_map, dxgi_unknown_string):
table_data = ''
for unknown_type_function in dxgi_to_type_map[dxgi_unknown_string]:
table_data += get_function_maps_string(unknown_type_function['type'], unknown_type_function['loadFunction'], 'true')
table_data += get_function_maps_string(unknown_type_function['type'], unknown_type_function['loadFunction'])
return table_data
......@@ -126,8 +125,8 @@ def create_dxgi_to_type_map(dst, json_data, internal_format_str):
def get_load_function_map_snippet(insert_map_string):
load_function_map_snippet = ''
load_function_map_snippet += ' static const std::map<GLenum, LoadImageFunctionInfo> loadFunctionsMap = []() {\n'
load_function_map_snippet += ' std::map<GLenum, LoadImageFunctionInfo> loadMap;\n'
load_function_map_snippet += ' static const std::map<GLenum, LoadImageFunction> loadFunctionsMap = []() {\n'
load_function_map_snippet += ' std::map<GLenum, LoadImageFunction> loadMap;\n'
load_function_map_snippet += insert_map_string
load_function_map_snippet += ' return loadMap;\n'
load_function_map_snippet += ' }();\n\n'
......@@ -158,7 +157,8 @@ def parse_json_into_switch_string(json_data):
insert_map_string = ''
types_already_in_loadmap = set()
for type_function in sorted(dxgi_format_item[1]):
insert_map_string += get_function_maps_string(type_function['type'], type_function['loadFunction'], type_function['requiresConversion'])
# type_function['requiresConversion'] element is not in use at the moment but may be needed later
insert_map_string += get_function_maps_string(type_function['type'], type_function['loadFunction'])
types_already_in_loadmap.add(type_function['type'])
# DXGI_FORMAT_UNKNOWN add ons
......@@ -166,7 +166,7 @@ def parse_json_into_switch_string(json_data):
for unknown_type_function in dxgi_to_type_map[dxgi_format_unknown]:
# Check that it's not already in the loadmap so it doesn't override the value
if unknown_type_function['type'] not in types_already_in_loadmap:
insert_map_string += get_function_maps_string(unknown_type_function['type'], unknown_type_function['loadFunction'], 'true')
insert_map_string += get_function_maps_string(unknown_type_function['type'], unknown_type_function['loadFunction'])
table_data += get_load_function_map_snippet(insert_map_string)
table_data += ' }\n'
......
......@@ -13,7 +13,6 @@
#include <map>
#include "libANGLE/renderer/d3d/d3d11/Renderer11.h"
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
namespace rx
{
......@@ -21,8 +20,8 @@ namespace rx
namespace d3d11
{
const std::map<GLenum, LoadImageFunctionInfo> &GetLoadFunctionsMap(GLenum internalFormat,
DXGI_FORMAT dxgiFormat);
const std::map<GLenum, LoadImageFunction> &GetLoadFunctionsMap(GLenum internalFormat,
DXGI_FORMAT dxgiFormat);
} // namespace d3d11
......
......@@ -22,18 +22,6 @@ namespace rx
namespace d3d11
{
struct LoadImageFunctionInfo
{
LoadImageFunctionInfo() : loadFunction(nullptr), requiresConversion(false) {}
LoadImageFunctionInfo(LoadImageFunction loadFunction, bool requiresConversion)
: loadFunction(loadFunction), requiresConversion(requiresConversion)
{
}
LoadImageFunction loadFunction;
bool requiresConversion;
};
struct TextureFormat
{
TextureFormat();
......@@ -49,7 +37,7 @@ struct TextureFormat
DXGI_FORMAT swizzleRTVFormat;
InitializeTextureDataFunction dataInitializerFunction;
typedef std::map<GLenum, LoadImageFunctionInfo> LoadFunctionMap;
typedef std::map<GLenum, LoadImageFunction> LoadFunctionMap;
LoadFunctionMap loadFunctions;
};
......@@ -61,4 +49,4 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalformat,
} // namespace rx
#endif // LIBANGLE_RENDERER_D3D_D3D11_TEXTUREFORMATTABLE_H_
#endif // LIBANGLE_RENDERER_D3D_D3D11_TEXTUREFORMATTABLE_H_
\ No newline at end of file
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