Commit 7acae0a1 by Jamie Madill

Add a centralized workarounds module.

This is a temporary home for the various workarounds we use for performance or to solve driver issues. Eventually we will want a standalone library we can use as part of Chromium or in ANGLE standalone. Re-land with member variable initialized. BUG=angle:729 Change-Id: If7f8f9596a39b2855366d9a67caebf6dd4197b55 Reviewed-on: https://chromium-review.googlesource.com/219868Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 57f20894
......@@ -242,6 +242,7 @@
<ClInclude Include="..\..\src\libGLESv2\validationES.h"/>
<ClInclude Include="..\..\src\libGLESv2\renderer\TextureImpl.h"/>
<ClInclude Include="..\..\src\libGLESv2\renderer\Renderer.h"/>
<ClInclude Include="..\..\src\libGLESv2\renderer\Workarounds.h"/>
<ClInclude Include="..\..\src\libGLESv2\renderer\ShaderImpl.h"/>
<ClInclude Include="..\..\src\libGLESv2\renderer\TransformFeedbackImpl.h"/>
<ClInclude Include="..\..\src\libGLESv2\renderer\ShaderExecutable.h"/>
......
......@@ -267,6 +267,9 @@
<None Include="..\..\src\libGLESv2\renderer\loadimage.inl">
<Filter>src\libGLESv2\renderer</Filter>
</None>
<ClInclude Include="..\..\src\libGLESv2\renderer\Workarounds.h">
<Filter>src\libGLESv2\renderer</Filter>
</ClInclude>
<ClInclude Include="..\..\src\libGLESv2\renderer\ShaderImpl.h">
<Filter>src\libGLESv2\renderer</Filter>
</ClInclude>
......
......@@ -115,6 +115,7 @@
'libGLESv2/renderer/TextureImpl.h',
'libGLESv2/renderer/TransformFeedbackImpl.h',
'libGLESv2/renderer/VertexArrayImpl.h',
'libGLESv2/renderer/Workarounds.h',
'libGLESv2/renderer/copyimage.cpp',
'libGLESv2/renderer/copyimage.h',
'libGLESv2/renderer/copyimage.inl',
......
......@@ -16,6 +16,7 @@
#include "libGLESv2/FramebufferAttachment.h"
#include "libGLESv2/renderer/Renderer.h"
#include "libGLESv2/renderer/RenderTarget.h"
#include "libGLESv2/renderer/Workarounds.h"
#include "libGLESv2/renderer/d3d/TextureD3D.h"
#include "common/utilities.h"
......@@ -689,12 +690,10 @@ ColorbufferInfo Framebuffer::getColorbuffersForRender() const
ASSERT(drawBufferState == GL_BACK || drawBufferState == (GL_COLOR_ATTACHMENT0_EXT + colorAttachment));
colorbuffersForRender.push_back(colorbuffer);
}
#if (ANGLE_MRT_PERF_WORKAROUND == ANGLE_WORKAROUND_DISABLED)
else
else if (!mRenderer->getWorkarounds().mrtPerfWorkaround)
{
colorbuffersForRender.push_back(NULL);
}
#endif
}
return colorbuffersForRender;
......
......@@ -24,11 +24,6 @@
#include <string>
#include <vector>
// TODO(jmadill): place this in workarounds library
#define ANGLE_WORKAROUND_ENABLED 1
#define ANGLE_WORKAROUND_DISABLED 2
#define ANGLE_MRT_PERF_WORKAROUND ANGLE_WORKAROUND_ENABLED
namespace sh
{
class HLSLBlockEncoder;
......
......@@ -250,13 +250,6 @@ enum VertexConversionType
VERTEX_CONVERT_BOTH = 3
};
enum D3DWorkaroundType
{
ANGLE_D3D_WORKAROUND_NONE,
ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION,
ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION
};
}
#endif // LIBGLESV2_ANGLETYPES_H_
......@@ -38,6 +38,7 @@ namespace rx
Renderer::Renderer(egl::Display *display)
: mDisplay(display),
mCapsInitialized(false),
mWorkaroundsInitialized(false),
mCurrentClientVersion(2)
{
}
......@@ -79,6 +80,17 @@ const gl::Extensions &Renderer::getRendererExtensions() const
return mExtensions;
}
const Workarounds &Renderer::getWorkarounds() const
{
if (!mWorkaroundsInitialized)
{
mWorkarounds = generateWorkarounds();
mWorkaroundsInitialized = true;
}
return mWorkarounds;
}
typedef Renderer *(*CreateRendererFunction)(egl::Display*, EGLNativeDisplayType, EGLint);
template <typename RendererType>
......
......@@ -15,6 +15,7 @@
#include "libGLESv2/Caps.h"
#include "common/NativeWindow.h"
#include "libGLESv2/Error.h"
#include "libGLESv2/renderer/Workarounds.h"
#include <cstdint>
......@@ -249,6 +250,8 @@ class Renderer
virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const = 0;
virtual GLenum getVertexComponentType(const gl::VertexFormat &vertexFormat) const = 0;
const Workarounds &getWorkarounds() const;
protected:
egl::Display *mDisplay;
......@@ -256,12 +259,16 @@ class Renderer
DISALLOW_COPY_AND_ASSIGN(Renderer);
virtual void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap* outTextureCaps, gl::Extensions *outExtensions) const = 0;
virtual Workarounds generateWorkarounds() const = 0;
mutable bool mCapsInitialized;
mutable gl::Caps mCaps;
mutable gl::TextureCapsMap mTextureCaps;
mutable gl::Extensions mExtensions;
mutable bool mWorkaroundsInitialized;
mutable Workarounds mWorkarounds;
int mCurrentClientVersion;
};
......
//
// Copyright (c) 2014 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// angletypes.h: Workarounds for driver bugs and other issues.
#ifndef LIBGLESV2_RENDERER_WORKAROUNDS_H_
#define LIBGLESV2_RENDERER_WORKAROUNDS_H_
// TODO(jmadill,zmo,geofflang): make a workarounds library that can operate
// independent of ANGLE's renderer. Workarounds should also be accessible
// outside of the Renderer.
namespace rx
{
enum D3DWorkaroundType
{
ANGLE_D3D_WORKAROUND_NONE,
ANGLE_D3D_WORKAROUND_SKIP_OPTIMIZATION,
ANGLE_D3D_WORKAROUND_MAX_OPTIMIZATION
};
struct Workarounds
{
Workarounds()
: mrtPerfWorkaround(false)
{}
bool mrtPerfWorkaround;
};
}
#endif // LIBGLESV2_RENDERER_WORKAROUNDS_H_
......@@ -10,6 +10,7 @@
#define LIBGLESV2_RENDERER_PROGRAMD3D_H_
#include "libGLESv2/renderer/ProgramImpl.h"
#include "libGLESv2/renderer/Workarounds.h"
#include <string>
#include <vector>
......
......@@ -10,6 +10,7 @@
#define LIBGLESV2_RENDERER_SHADERD3D_H_
#include "libGLESv2/renderer/ShaderImpl.h"
#include "libGLESv2/renderer/Workarounds.h"
#include "libGLESv2/Shader.h"
#include <map>
......
......@@ -3156,4 +3156,9 @@ void Renderer11::generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureC
d3d11_gl::GenerateCaps(mDevice, outCaps, outTextureCaps, outExtensions);
}
Workarounds Renderer11::generateWorkarounds() const
{
return d3d11::GenerateWorkarounds();
}
}
......@@ -205,6 +205,7 @@ class Renderer11 : public Renderer
DISALLOW_COPY_AND_ASSIGN(Renderer11);
virtual void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions) const;
virtual Workarounds generateWorkarounds() const;
gl::Error drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
gl::Error drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances);
......
......@@ -10,6 +10,7 @@
#include "libGLESv2/renderer/d3d/d3d11/renderer11_utils.h"
#include "libGLESv2/renderer/d3d/d3d11/formatutils11.h"
#include "libGLESv2/renderer/d3d/d3d11/RenderTarget11.h"
#include "libGLESv2/renderer/Workarounds.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/Framebuffer.h"
......@@ -1071,6 +1072,13 @@ RenderTarget11 *GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment)
return RenderTarget11::makeRenderTarget11(renderTarget);
}
Workarounds GenerateWorkarounds()
{
Workarounds workarounds;
workarounds.mrtPerfWorkaround = true;
return workarounds;
}
}
}
......@@ -23,6 +23,7 @@ class FramebufferAttachment;
namespace rx
{
class RenderTarget11;
struct Workarounds;
namespace gl_d3d11
{
......@@ -178,6 +179,8 @@ inline void SetBufferData(ID3D11DeviceContext *context, ID3D11Buffer *constantBu
RenderTarget11 *GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment);
Workarounds GenerateWorkarounds();
}
}
......
......@@ -3111,4 +3111,9 @@ void Renderer9::generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCa
d3d9_gl::GenerateCaps(mD3d9, mDevice, mDeviceType, mAdapter, outCaps, outTextureCaps, outExtensions);
}
Workarounds Renderer9::generateWorkarounds() const
{
return d3d9::GenerateWorkarounds();
}
}
......@@ -202,6 +202,7 @@ class Renderer9 : public Renderer
DISALLOW_COPY_AND_ASSIGN(Renderer9);
virtual void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions) const;
virtual Workarounds generateWorkarounds() const;
void release();
......
......@@ -9,6 +9,7 @@
#include "libGLESv2/renderer/d3d/d3d9/renderer9_utils.h"
#include "libGLESv2/renderer/d3d/d3d9/formatutils9.h"
#include "libGLESv2/renderer/Workarounds.h"
#include "libGLESv2/formatutils.h"
#include "libGLESv2/Framebuffer.h"
#include "libGLESv2/renderer/d3d/d3d9/RenderTarget9.h"
......@@ -537,6 +538,13 @@ RenderTarget9 *GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment)
return RenderTarget9::makeRenderTarget9(renderTarget);
}
Workarounds GenerateWorkarounds()
{
Workarounds workarounds;
workarounds.mrtPerfWorkaround = true;
return workarounds;
}
}
}
......@@ -21,6 +21,7 @@ class FramebufferAttachment;
namespace rx
{
class RenderTarget9;
struct Workarounds;
namespace gl_d3d9
{
......@@ -75,6 +76,7 @@ inline bool isDeviceLostError(HRESULT errorCode)
}
RenderTarget9 *GetAttachmentRenderTarget(gl::FramebufferAttachment *attachment);
Workarounds GenerateWorkarounds();
}
......
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