Commit 7d32aa5f by Jamie Madill

Revert "D3D11 Texture refactoring: Store ANGLEFormat in TextureStorage11"

Failing Windows Debug WebGL tests: https://build.chromium.org/p/chromium.gpu.fyi/builders/Win7%20Debug%20%28NVIDIA%29/builds/13587 Seems to fail in and around: [ FAILED ] WebglConformance.conformance_renderbuffers_framebuffer_object_attachment (320392 ms) [ RUN ] WebglConformance.conformance_renderbuffers_framebuffer_state_restoration BUG=angleproject:1244 This reverts commit d72c61c6. Change-Id: Id84d6988bc1a3530d8dde4c36d18b735f3de06fc Reviewed-on: https://chromium-review.googlesource.com/329621Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d72c61c6
...@@ -178,7 +178,7 @@ static unsigned int getDSVSubresourceIndex(ID3D11Resource *resource, ID3D11Depth ...@@ -178,7 +178,7 @@ static unsigned int getDSVSubresourceIndex(ID3D11Resource *resource, ID3D11Depth
return D3D11CalcSubresource(mipSlice, arraySlice, mipLevels); return D3D11CalcSubresource(mipSlice, arraySlice, mipLevels);
} }
RenderTarget11::RenderTarget11(d3d11::ANGLEFormat angleFormat) : mANGLEFormat(angleFormat) RenderTarget11::RenderTarget11()
{ {
} }
...@@ -211,17 +211,9 @@ void RenderTarget11::signalDirty() ...@@ -211,17 +211,9 @@ void RenderTarget11::signalDirty()
mDirtyCallbacks.clear(); mDirtyCallbacks.clear();
} }
TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
ID3D11Resource *resource, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples)
ID3D11ShaderResourceView *srv, : mWidth(width),
GLenum internalFormat,
d3d11::ANGLEFormat angleFormat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLsizei samples)
: RenderTarget11(angleFormat),
mWidth(width),
mHeight(height), mHeight(height),
mDepth(depth), mDepth(depth),
mInternalFormat(internalFormat), mInternalFormat(internalFormat),
...@@ -256,20 +248,11 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, ...@@ -256,20 +248,11 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
mRenderTarget->GetDesc(&desc); mRenderTarget->GetDesc(&desc);
mDXGIFormat = desc.Format; mDXGIFormat = desc.Format;
} }
ASSERT(mANGLEFormat != d3d11::ANGLE_FORMAT_NONE || (mWidth == 0 && mHeight == 0)); }
}
TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples)
ID3D11Resource *resource, : mWidth(width),
ID3D11ShaderResourceView *srv,
GLenum internalFormat,
d3d11::ANGLEFormat angleFormat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLsizei samples)
: RenderTarget11(angleFormat),
mWidth(width),
mHeight(height), mHeight(height),
mDepth(depth), mDepth(depth),
mInternalFormat(internalFormat), mInternalFormat(internalFormat),
...@@ -304,7 +287,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, ...@@ -304,7 +287,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv,
mDepthStencil->GetDesc(&desc); mDepthStencil->GetDesc(&desc);
mDXGIFormat = desc.Format; mDXGIFormat = desc.Format;
} }
ASSERT(mANGLEFormat != d3d11::ANGLE_FORMAT_NONE || (mWidth == 0 && mHeight == 0));
} }
TextureRenderTarget11::~TextureRenderTarget11() TextureRenderTarget11::~TextureRenderTarget11()
...@@ -370,19 +352,12 @@ DXGI_FORMAT TextureRenderTarget11::getDXGIFormat() const ...@@ -370,19 +352,12 @@ DXGI_FORMAT TextureRenderTarget11::getDXGIFormat() const
return mDXGIFormat; return mDXGIFormat;
} }
SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain, SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain, Renderer11 *renderer, bool depth)
Renderer11 *renderer, : mSwapChain(swapChain),
bool depth)
: RenderTarget11(d3d11::ANGLE_FORMAT_NONE), // format will be determined in constructor body
mSwapChain(swapChain),
mRenderer(renderer), mRenderer(renderer),
mDepth(depth) mDepth(depth)
{ {
ASSERT(mSwapChain); ASSERT(mSwapChain);
mANGLEFormat = d3d11::GetTextureFormatInfo(getInternalFormatInternal(),
mRenderer->getRenderer11DeviceCaps())
.formatSet.format;
} }
SurfaceRenderTarget11::~SurfaceRenderTarget11() SurfaceRenderTarget11::~SurfaceRenderTarget11()
...@@ -406,11 +381,6 @@ GLsizei SurfaceRenderTarget11::getDepth() const ...@@ -406,11 +381,6 @@ GLsizei SurfaceRenderTarget11::getDepth() const
GLenum SurfaceRenderTarget11::getInternalFormat() const GLenum SurfaceRenderTarget11::getInternalFormat() const
{ {
return getInternalFormatInternal();
}
GLenum SurfaceRenderTarget11::getInternalFormatInternal() const
{
return (mDepth ? mSwapChain->GetDepthBufferInternalFormat() : mSwapChain->GetRenderTargetInternalFormat()); return (mDepth ? mSwapChain->GetDepthBufferInternalFormat() : mSwapChain->GetRenderTargetInternalFormat());
} }
...@@ -437,8 +407,7 @@ ID3D11DepthStencilView *SurfaceRenderTarget11::getDepthStencilView() const ...@@ -437,8 +407,7 @@ ID3D11DepthStencilView *SurfaceRenderTarget11::getDepthStencilView() const
ID3D11ShaderResourceView *SurfaceRenderTarget11::getShaderResourceView() const ID3D11ShaderResourceView *SurfaceRenderTarget11::getShaderResourceView() const
{ {
return (mDepth ? mSwapChain->getDepthStencilShaderResource() return (mDepth ? mSwapChain->getDepthStencilShaderResource() : mSwapChain->getRenderTargetShaderResource());
: mSwapChain->getRenderTargetShaderResource());
} }
unsigned int SurfaceRenderTarget11::getSubresourceIndex() const unsigned int SurfaceRenderTarget11::getSubresourceIndex() const
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#define LIBANGLE_RENDERER_D3D_D3D11_RENDERTARGET11_H_ #define LIBANGLE_RENDERER_D3D_D3D11_RENDERTARGET11_H_
#include "libANGLE/renderer/d3d/RenderTargetD3D.h" #include "libANGLE/renderer/d3d/RenderTargetD3D.h"
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h" #include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
...@@ -23,7 +22,7 @@ class Renderer11; ...@@ -23,7 +22,7 @@ class Renderer11;
class RenderTarget11 : public RenderTargetD3D class RenderTarget11 : public RenderTargetD3D
{ {
public: public:
RenderTarget11(d3d11::ANGLEFormat angleFormat); RenderTarget11();
virtual ~RenderTarget11(); virtual ~RenderTarget11();
virtual ID3D11Resource *getTexture() const = 0; virtual ID3D11Resource *getTexture() const = 0;
...@@ -39,36 +38,18 @@ class RenderTarget11 : public RenderTargetD3D ...@@ -39,36 +38,18 @@ class RenderTarget11 : public RenderTargetD3D
void removeDirtyCallback(const NotificationCallback *callback); void removeDirtyCallback(const NotificationCallback *callback);
void signalDirty() override; void signalDirty() override;
d3d11::ANGLEFormat getANGLEFormat() const { return mANGLEFormat; }
protected: protected:
std::set<const NotificationCallback *> mDirtyCallbacks; std::set<const NotificationCallback *> mDirtyCallbacks;
d3d11::ANGLEFormat mANGLEFormat;
}; };
class TextureRenderTarget11 : public RenderTarget11 class TextureRenderTarget11 : public RenderTarget11
{ {
public: public:
// TextureRenderTarget11 takes ownership of any D3D11 resources it is given and will AddRef them // TextureRenderTarget11 takes ownership of any D3D11 resources it is given and will AddRef them
TextureRenderTarget11(ID3D11RenderTargetView *rtv, TextureRenderTarget11(ID3D11RenderTargetView *rtv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
ID3D11Resource *resource, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples);
ID3D11ShaderResourceView *srv, TextureRenderTarget11(ID3D11DepthStencilView *dsv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
GLenum internalFormat, GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples);
d3d11::ANGLEFormat angleFormat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLsizei samples);
TextureRenderTarget11(ID3D11DepthStencilView *dsv,
ID3D11Resource *resource,
ID3D11ShaderResourceView *srv,
GLenum internalFormat,
d3d11::ANGLEFormat angleFormat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLsizei samples);
virtual ~TextureRenderTarget11(); virtual ~TextureRenderTarget11();
GLsizei getWidth() const override; GLsizei getWidth() const override;
...@@ -123,10 +104,6 @@ class SurfaceRenderTarget11 : public RenderTarget11 ...@@ -123,10 +104,6 @@ class SurfaceRenderTarget11 : public RenderTarget11
DXGI_FORMAT getDXGIFormat() const override; DXGI_FORMAT getDXGIFormat() const override;
private: private:
// The internal versions of the functions are needed so that they can be safely called
// from the constructor.
GLenum getInternalFormatInternal() const;
SwapChain11 *mSwapChain; SwapChain11 *mSwapChain;
Renderer11 *mRenderer; Renderer11 *mRenderer;
bool mDepth; bool mDepth;
......
...@@ -3131,9 +3131,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3131,9 +3131,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target depth stencil view, result: 0x%X.", result); return gl::Error(GL_OUT_OF_MEMORY, "Failed to create render target depth stencil view, result: 0x%X.", result);
} }
*outRT = *outRT = new TextureRenderTarget11(dsv, texture, srv, format, width, height, 1, supportedSamples);
new TextureRenderTarget11(dsv, texture, srv, format, formatInfo.formatSet.format,
width, height, 1, supportedSamples);
SafeRelease(dsv); SafeRelease(dsv);
} }
...@@ -3160,9 +3158,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3160,9 +3158,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
mDeviceContext->ClearRenderTargetView(rtv, clearValues); mDeviceContext->ClearRenderTargetView(rtv, clearValues);
} }
*outRT = *outRT = new TextureRenderTarget11(rtv, texture, srv, format, width, height, 1, supportedSamples);
new TextureRenderTarget11(rtv, texture, srv, format, formatInfo.formatSet.format,
width, height, 1, supportedSamples);
SafeRelease(rtv); SafeRelease(rtv);
} }
...@@ -3176,9 +3172,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G ...@@ -3176,9 +3172,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
} }
else else
{ {
*outRT = new TextureRenderTarget11(reinterpret_cast<ID3D11RenderTargetView *>(nullptr), *outRT = new TextureRenderTarget11(reinterpret_cast<ID3D11RenderTargetView*>(NULL), NULL, NULL, format, width, height, 1, supportedSamples);
nullptr, nullptr, format, d3d11::ANGLE_FORMAT_NONE,
width, height, 1, supportedSamples);
} }
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
......
...@@ -136,8 +136,7 @@ bool SupportsFormat(const Renderer11DeviceCaps &deviceCaps) ...@@ -136,8 +136,7 @@ bool SupportsFormat(const Renderer11DeviceCaps &deviceCaps)
}} // namespace }} // namespace
ANGLEFormatSet::ANGLEFormatSet() ANGLEFormatSet::ANGLEFormatSet()
: format(ANGLE_FORMAT_NONE), : texFormat(DXGI_FORMAT_UNKNOWN),
texFormat(DXGI_FORMAT_UNKNOWN),
srvFormat(DXGI_FORMAT_UNKNOWN), srvFormat(DXGI_FORMAT_UNKNOWN),
rtvFormat(DXGI_FORMAT_UNKNOWN), rtvFormat(DXGI_FORMAT_UNKNOWN),
dsvFormat(DXGI_FORMAT_UNKNOWN), dsvFormat(DXGI_FORMAT_UNKNOWN),
...@@ -150,11 +149,10 @@ ANGLEFormatSet::ANGLEFormatSet() ...@@ -150,11 +149,10 @@ ANGLEFormatSet::ANGLEFormatSet()
// This function allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and // This function allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and
// DSVs given a GL internal format. // DSVs given a GL internal format.
TextureFormat::TextureFormat(GLenum internalFormat, TextureFormat::TextureFormat(GLenum internalFormat,
const ANGLEFormat angleFormat, const ANGLEFormatSet &formatSet,
InitializeTextureDataFunction internalFormatInitializer) InitializeTextureDataFunction internalFormatInitializer)
: dataInitializerFunction(internalFormatInitializer) : formatSet(formatSet), dataInitializerFunction(internalFormatInitializer)
{{ {{
formatSet = GetANGLEFormatSet(angleFormat);
swizzleFormatSet = GetANGLEFormatSet(formatSet.swizzleFormat); swizzleFormatSet = GetANGLEFormatSet(formatSet.swizzleFormat);
// Gather all the load functions for this internal format // Gather all the load functions for this internal format
...@@ -163,14 +161,12 @@ TextureFormat::TextureFormat(GLenum internalFormat, ...@@ -163,14 +161,12 @@ TextureFormat::TextureFormat(GLenum internalFormat,
ASSERT(loadFunctions.size() != 0 || internalFormat == GL_NONE); ASSERT(loadFunctions.size() != 0 || internalFormat == GL_NONE);
}} }}
ANGLEFormatSet::ANGLEFormatSet(ANGLEFormat format, ANGLEFormatSet::ANGLEFormatSet(DXGI_FORMAT texFormat,
DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat, DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat, DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat, DXGI_FORMAT dsvFormat,
ANGLEFormat swizzleFormat) ANGLEFormat swizzleFormat)
: format(format), : texFormat(texFormat),
texFormat(texFormat),
srvFormat(srvFormat), srvFormat(srvFormat),
rtvFormat(rtvFormat), rtvFormat(rtvFormat),
dsvFormat(dsvFormat), dsvFormat(dsvFormat),
...@@ -206,7 +202,7 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat, ...@@ -206,7 +202,7 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
}} }}
// clang-format on // clang-format on
static const TextureFormat defaultInfo(GL_NONE, ANGLE_FORMAT_NONE, nullptr); static const TextureFormat defaultInfo(GL_NONE, ANGLEFormatSet(), nullptr);
return defaultInfo; return defaultInfo;
}} // GetTextureFormatInfo }} // GetTextureFormatInfo
...@@ -351,7 +347,7 @@ def get_texture_format_item(idx, internal_format, requirements_fn, angle_format_ ...@@ -351,7 +347,7 @@ def get_texture_format_item(idx, internal_format, requirements_fn, angle_format_
indent += ' ' indent += ' '
table_data += indent + 'static const TextureFormat textureFormat(internalFormat,\n' table_data += indent + 'static const TextureFormat textureFormat(internalFormat,\n'
table_data += indent + ' ' + angle_format_id + ',\n' table_data += indent + ' GetANGLEFormatSet(' + angle_format_id + '),\n'
table_data += indent + ' ' + internal_format_initializer + ');\n' table_data += indent + ' ' + internal_format_initializer + ');\n'
table_data += indent + 'return textureFormat;\n' table_data += indent + 'return textureFormat;\n'
...@@ -396,8 +392,7 @@ def parse_json_into_switch_angle_format_string(json_data): ...@@ -396,8 +392,7 @@ def parse_json_into_switch_angle_format_string(json_data):
dsv_format = angle_format["dsvFormat"] if "dsvFormat" in angle_format else "DXGI_FORMAT_UNKNOWN" dsv_format = angle_format["dsvFormat"] if "dsvFormat" in angle_format else "DXGI_FORMAT_UNKNOWN"
swizzle_format = get_swizzle_format_id(angle_format_item[0], angle_format) swizzle_format = get_swizzle_format_id(angle_format_item[0], angle_format)
table_data += ' {\n' table_data += ' {\n'
table_data += ' static const ANGLEFormatSet formatInfo(' + angle_format_item[0] + ',\n' table_data += ' static const ANGLEFormatSet formatInfo(' + tex_format + ',\n'
table_data += ' ' + tex_format + ',\n'
table_data += ' ' + srv_format + ',\n' table_data += ' ' + srv_format + ',\n'
table_data += ' ' + rtv_format + ',\n' table_data += ' ' + rtv_format + ',\n'
table_data += ' ' + dsv_format + ',\n' table_data += ' ' + dsv_format + ',\n'
...@@ -436,9 +431,7 @@ with open('texture_format_map.json') as texture_format_map_file: ...@@ -436,9 +431,7 @@ with open('texture_format_map.json') as texture_format_map_file:
texture_format_cases = parse_json_into_switch_texture_format_string(json_map, json_data) texture_format_cases = parse_json_into_switch_texture_format_string(json_map, json_data)
angle_format_cases = parse_json_into_switch_angle_format_string(json_data) angle_format_cases = parse_json_into_switch_angle_format_string(json_data)
output_cpp = template_texture_format_table_autogen_cpp.format( output_cpp = template_texture_format_table_autogen_cpp.format(texture_format_info_cases=texture_format_cases, angle_format_info_cases=angle_format_cases)
texture_format_info_cases=texture_format_cases,
angle_format_info_cases=angle_format_cases)
with open('texture_format_table_autogen.cpp', 'wt') as out_file: with open('texture_format_table_autogen.cpp', 'wt') as out_file:
out_file.write(output_cpp) out_file.write(output_cpp)
out_file.close() out_file.close()
......
...@@ -38,8 +38,7 @@ struct LoadImageFunctionInfo ...@@ -38,8 +38,7 @@ struct LoadImageFunctionInfo
struct ANGLEFormatSet struct ANGLEFormatSet
{ {
ANGLEFormatSet(); ANGLEFormatSet();
ANGLEFormatSet(ANGLEFormat format, ANGLEFormatSet(DXGI_FORMAT texFormat,
DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat, DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat, DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat, DXGI_FORMAT dsvFormat,
...@@ -47,8 +46,6 @@ struct ANGLEFormatSet ...@@ -47,8 +46,6 @@ struct ANGLEFormatSet
ANGLEFormatSet(const ANGLEFormatSet &) = default; ANGLEFormatSet(const ANGLEFormatSet &) = default;
ANGLEFormatSet &operator=(const ANGLEFormatSet &) = default; ANGLEFormatSet &operator=(const ANGLEFormatSet &) = default;
ANGLEFormat format;
DXGI_FORMAT texFormat; DXGI_FORMAT texFormat;
DXGI_FORMAT srvFormat; DXGI_FORMAT srvFormat;
DXGI_FORMAT rtvFormat; DXGI_FORMAT rtvFormat;
...@@ -60,7 +57,7 @@ struct ANGLEFormatSet ...@@ -60,7 +57,7 @@ struct ANGLEFormatSet
struct TextureFormat : public angle::NonCopyable struct TextureFormat : public angle::NonCopyable
{ {
TextureFormat(GLenum internalFormat, TextureFormat(GLenum internalFormat,
const ANGLEFormat angleFormat, const ANGLEFormatSet &formatSet,
InitializeTextureDataFunction internalFormatInitializer); InitializeTextureDataFunction internalFormatInitializer);
ANGLEFormatSet formatSet; ANGLEFormatSet formatSet;
......
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