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
return D3D11CalcSubresource(mipSlice, arraySlice, mipLevels);
}
RenderTarget11::RenderTarget11(d3d11::ANGLEFormat angleFormat) : mANGLEFormat(angleFormat)
RenderTarget11::RenderTarget11()
{
}
......@@ -211,17 +211,9 @@ void RenderTarget11::signalDirty()
mDirtyCallbacks.clear();
}
TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
ID3D11Resource *resource,
ID3D11ShaderResourceView *srv,
GLenum internalFormat,
d3d11::ANGLEFormat angleFormat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLsizei samples)
: RenderTarget11(angleFormat),
mWidth(width),
TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples)
: mWidth(width),
mHeight(height),
mDepth(depth),
mInternalFormat(internalFormat),
......@@ -256,20 +248,11 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11RenderTargetView *rtv,
mRenderTarget->GetDesc(&desc);
mDXGIFormat = desc.Format;
}
ASSERT(mANGLEFormat != d3d11::ANGLE_FORMAT_NONE || (mWidth == 0 && mHeight == 0));
}
TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv,
ID3D11Resource *resource,
ID3D11ShaderResourceView *srv,
GLenum internalFormat,
d3d11::ANGLEFormat angleFormat,
GLsizei width,
GLsizei height,
GLsizei depth,
GLsizei samples)
: RenderTarget11(angleFormat),
mWidth(width),
}
TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples)
: mWidth(width),
mHeight(height),
mDepth(depth),
mInternalFormat(internalFormat),
......@@ -304,7 +287,6 @@ TextureRenderTarget11::TextureRenderTarget11(ID3D11DepthStencilView *dsv,
mDepthStencil->GetDesc(&desc);
mDXGIFormat = desc.Format;
}
ASSERT(mANGLEFormat != d3d11::ANGLE_FORMAT_NONE || (mWidth == 0 && mHeight == 0));
}
TextureRenderTarget11::~TextureRenderTarget11()
......@@ -370,19 +352,12 @@ DXGI_FORMAT TextureRenderTarget11::getDXGIFormat() const
return mDXGIFormat;
}
SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain,
Renderer11 *renderer,
bool depth)
: RenderTarget11(d3d11::ANGLE_FORMAT_NONE), // format will be determined in constructor body
mSwapChain(swapChain),
SurfaceRenderTarget11::SurfaceRenderTarget11(SwapChain11 *swapChain, Renderer11 *renderer, bool depth)
: mSwapChain(swapChain),
mRenderer(renderer),
mDepth(depth)
{
ASSERT(mSwapChain);
mANGLEFormat = d3d11::GetTextureFormatInfo(getInternalFormatInternal(),
mRenderer->getRenderer11DeviceCaps())
.formatSet.format;
}
SurfaceRenderTarget11::~SurfaceRenderTarget11()
......@@ -406,11 +381,6 @@ GLsizei SurfaceRenderTarget11::getDepth() const
GLenum SurfaceRenderTarget11::getInternalFormat() const
{
return getInternalFormatInternal();
}
GLenum SurfaceRenderTarget11::getInternalFormatInternal() const
{
return (mDepth ? mSwapChain->GetDepthBufferInternalFormat() : mSwapChain->GetRenderTargetInternalFormat());
}
......@@ -437,8 +407,7 @@ ID3D11DepthStencilView *SurfaceRenderTarget11::getDepthStencilView() const
ID3D11ShaderResourceView *SurfaceRenderTarget11::getShaderResourceView() const
{
return (mDepth ? mSwapChain->getDepthStencilShaderResource()
: mSwapChain->getRenderTargetShaderResource());
return (mDepth ? mSwapChain->getDepthStencilShaderResource() : mSwapChain->getRenderTargetShaderResource());
}
unsigned int SurfaceRenderTarget11::getSubresourceIndex() const
......
......@@ -11,7 +11,6 @@
#define LIBANGLE_RENDERER_D3D_D3D11_RENDERTARGET11_H_
#include "libANGLE/renderer/d3d/RenderTargetD3D.h"
#include "libANGLE/renderer/d3d/d3d11/texture_format_table.h"
#include "libANGLE/renderer/d3d/d3d11/renderer11_utils.h"
......@@ -23,7 +22,7 @@ class Renderer11;
class RenderTarget11 : public RenderTargetD3D
{
public:
RenderTarget11(d3d11::ANGLEFormat angleFormat);
RenderTarget11();
virtual ~RenderTarget11();
virtual ID3D11Resource *getTexture() const = 0;
......@@ -39,36 +38,18 @@ class RenderTarget11 : public RenderTargetD3D
void removeDirtyCallback(const NotificationCallback *callback);
void signalDirty() override;
d3d11::ANGLEFormat getANGLEFormat() const { return mANGLEFormat; }
protected:
std::set<const NotificationCallback *> mDirtyCallbacks;
d3d11::ANGLEFormat mANGLEFormat;
};
class TextureRenderTarget11 : public RenderTarget11
{
public:
// TextureRenderTarget11 takes ownership of any D3D11 resources it is given and will AddRef them
TextureRenderTarget11(ID3D11RenderTargetView *rtv,
ID3D11Resource *resource,
ID3D11ShaderResourceView *srv,
GLenum internalFormat,
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);
TextureRenderTarget11(ID3D11RenderTargetView *rtv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples);
TextureRenderTarget11(ID3D11DepthStencilView *dsv, ID3D11Resource *resource, ID3D11ShaderResourceView *srv,
GLenum internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLsizei samples);
virtual ~TextureRenderTarget11();
GLsizei getWidth() const override;
......@@ -123,10 +104,6 @@ class SurfaceRenderTarget11 : public RenderTarget11
DXGI_FORMAT getDXGIFormat() const override;
private:
// The internal versions of the functions are needed so that they can be safely called
// from the constructor.
GLenum getInternalFormatInternal() const;
SwapChain11 *mSwapChain;
Renderer11 *mRenderer;
bool mDepth;
......
......@@ -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);
}
*outRT =
new TextureRenderTarget11(dsv, texture, srv, format, formatInfo.formatSet.format,
width, height, 1, supportedSamples);
*outRT = new TextureRenderTarget11(dsv, texture, srv, format, width, height, 1, supportedSamples);
SafeRelease(dsv);
}
......@@ -3160,9 +3158,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
mDeviceContext->ClearRenderTargetView(rtv, clearValues);
}
*outRT =
new TextureRenderTarget11(rtv, texture, srv, format, formatInfo.formatSet.format,
width, height, 1, supportedSamples);
*outRT = new TextureRenderTarget11(rtv, texture, srv, format, width, height, 1, supportedSamples);
SafeRelease(rtv);
}
......@@ -3176,9 +3172,7 @@ gl::Error Renderer11::createRenderTarget(int width, int height, GLenum format, G
}
else
{
*outRT = new TextureRenderTarget11(reinterpret_cast<ID3D11RenderTargetView *>(nullptr),
nullptr, nullptr, format, d3d11::ANGLE_FORMAT_NONE,
width, height, 1, supportedSamples);
*outRT = new TextureRenderTarget11(reinterpret_cast<ID3D11RenderTargetView*>(NULL), NULL, NULL, format, width, height, 1, supportedSamples);
}
return gl::Error(GL_NO_ERROR);
......
......@@ -136,8 +136,7 @@ bool SupportsFormat(const Renderer11DeviceCaps &deviceCaps)
}} // namespace
ANGLEFormatSet::ANGLEFormatSet()
: format(ANGLE_FORMAT_NONE),
texFormat(DXGI_FORMAT_UNKNOWN),
: texFormat(DXGI_FORMAT_UNKNOWN),
srvFormat(DXGI_FORMAT_UNKNOWN),
rtvFormat(DXGI_FORMAT_UNKNOWN),
dsvFormat(DXGI_FORMAT_UNKNOWN),
......@@ -150,11 +149,10 @@ ANGLEFormatSet::ANGLEFormatSet()
// This function allows querying for the DXGI texture formats to use for textures, SRVs, RTVs and
// DSVs given a GL internal format.
TextureFormat::TextureFormat(GLenum internalFormat,
const ANGLEFormat angleFormat,
const ANGLEFormatSet &formatSet,
InitializeTextureDataFunction internalFormatInitializer)
: dataInitializerFunction(internalFormatInitializer)
: formatSet(formatSet), dataInitializerFunction(internalFormatInitializer)
{{
formatSet = GetANGLEFormatSet(angleFormat);
swizzleFormatSet = GetANGLEFormatSet(formatSet.swizzleFormat);
// Gather all the load functions for this internal format
......@@ -163,14 +161,12 @@ TextureFormat::TextureFormat(GLenum internalFormat,
ASSERT(loadFunctions.size() != 0 || internalFormat == GL_NONE);
}}
ANGLEFormatSet::ANGLEFormatSet(ANGLEFormat format,
DXGI_FORMAT texFormat,
ANGLEFormatSet::ANGLEFormatSet(DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat,
ANGLEFormat swizzleFormat)
: format(format),
texFormat(texFormat),
: texFormat(texFormat),
srvFormat(srvFormat),
rtvFormat(rtvFormat),
dsvFormat(dsvFormat),
......@@ -206,7 +202,7 @@ const TextureFormat &GetTextureFormatInfo(GLenum internalFormat,
}}
// clang-format on
static const TextureFormat defaultInfo(GL_NONE, ANGLE_FORMAT_NONE, nullptr);
static const TextureFormat defaultInfo(GL_NONE, ANGLEFormatSet(), nullptr);
return defaultInfo;
}} // GetTextureFormatInfo
......@@ -351,7 +347,7 @@ def get_texture_format_item(idx, internal_format, requirements_fn, angle_format_
indent += ' '
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 + 'return textureFormat;\n'
......@@ -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"
swizzle_format = get_swizzle_format_id(angle_format_item[0], angle_format)
table_data += ' {\n'
table_data += ' static const ANGLEFormatSet formatInfo(' + angle_format_item[0] + ',\n'
table_data += ' ' + tex_format + ',\n'
table_data += ' static const ANGLEFormatSet formatInfo(' + tex_format + ',\n'
table_data += ' ' + srv_format + ',\n'
table_data += ' ' + rtv_format + ',\n'
table_data += ' ' + dsv_format + ',\n'
......@@ -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)
angle_format_cases = parse_json_into_switch_angle_format_string(json_data)
output_cpp = template_texture_format_table_autogen_cpp.format(
texture_format_info_cases=texture_format_cases,
angle_format_info_cases=angle_format_cases)
output_cpp = template_texture_format_table_autogen_cpp.format(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:
out_file.write(output_cpp)
out_file.close()
......
......@@ -38,8 +38,7 @@ struct LoadImageFunctionInfo
struct ANGLEFormatSet
{
ANGLEFormatSet();
ANGLEFormatSet(ANGLEFormat format,
DXGI_FORMAT texFormat,
ANGLEFormatSet(DXGI_FORMAT texFormat,
DXGI_FORMAT srvFormat,
DXGI_FORMAT rtvFormat,
DXGI_FORMAT dsvFormat,
......@@ -47,8 +46,6 @@ struct ANGLEFormatSet
ANGLEFormatSet(const ANGLEFormatSet &) = default;
ANGLEFormatSet &operator=(const ANGLEFormatSet &) = default;
ANGLEFormat format;
DXGI_FORMAT texFormat;
DXGI_FORMAT srvFormat;
DXGI_FORMAT rtvFormat;
......@@ -60,7 +57,7 @@ struct ANGLEFormatSet
struct TextureFormat : public angle::NonCopyable
{
TextureFormat(GLenum internalFormat,
const ANGLEFormat angleFormat,
const ANGLEFormatSet &formatSet,
InitializeTextureDataFunction internalFormatInitializer);
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