Commit 811b6352 by Jamie Madill

Add a script to generate a new Renderer.

Also refactor our current Impl headers slightly to facilitate parsing by the generation script. BUG=angle:905 Change-Id: Ib86cff71d18e7f911cf526b27b8a82757bacd738 Reviewed-on: https://chromium-review.googlesource.com/245497Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent b0e83f46
...@@ -8,7 +8,9 @@ ...@@ -8,7 +8,9 @@
// extension and GLES3 sync objects. // extension and GLES3 sync objects.
#include "libANGLE/Fence.h" #include "libANGLE/Fence.h"
#include "libANGLE/renderer/FenceImpl.h"
#include "libANGLE/renderer/FenceNVImpl.h"
#include "libANGLE/renderer/FenceSyncImpl.h"
#include "libANGLE/renderer/Renderer.h" #include "libANGLE/renderer/Renderer.h"
#include "common/utilities.h" #include "common/utilities.h"
......
...@@ -8,13 +8,14 @@ ...@@ -8,13 +8,14 @@
// objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108. // objects and related functionality. [OpenGL ES 2.0.24] section 4.4.3 page 108.
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "common/utilities.h"
#include "libANGLE/Renderbuffer.h"
#include "libANGLE/Texture.h" #include "libANGLE/Texture.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/Renderbuffer.h" #include "libANGLE/renderer/DefaultAttachmentImpl.h"
#include "libANGLE/renderer/FramebufferImpl.h" #include "libANGLE/renderer/FramebufferImpl.h"
#include "common/utilities.h"
namespace gl namespace gl
{ {
......
//
// Copyright 2015 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.
//
// DefaultAttachmentImpl.h: Defines the abstract rx::DefaultAttachmentImpl class.
#ifndef LIBANGLE_RENDERER_DEFAULTATTACHMENTIMPL_H_
#define LIBANGLE_RENDERER_DEFAULTATTACHMENTIMPL_H_
#include "angle_gl.h"
#include "common/angleutils.h"
namespace rx
{
class DefaultAttachmentImpl
{
public:
DefaultAttachmentImpl() {}
virtual ~DefaultAttachmentImpl() {}
virtual GLsizei getWidth() const = 0;
virtual GLsizei getHeight() const = 0;
virtual GLenum getInternalFormat() const = 0;
virtual GLsizei getSamples() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(DefaultAttachmentImpl);
};
}
#endif // LIBANGLE_RENDERER_DEFAULTATTACHMENTIMPL_H_
...@@ -11,7 +11,9 @@ ...@@ -11,7 +11,9 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/Caps.h" #include "libANGLE/Caps.h"
#include "libANGLE/Config.h"
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
#include "libANGLE/renderer/Renderer.h"
#include <set> #include <set>
#include <vector> #include <vector>
...@@ -21,7 +23,6 @@ namespace egl ...@@ -21,7 +23,6 @@ namespace egl
class AttributeMap; class AttributeMap;
class Display; class Display;
struct Config; struct Config;
class ConfigSet;
class Surface; class Surface;
} }
...@@ -63,10 +64,10 @@ class DisplayImpl ...@@ -63,10 +64,10 @@ class DisplayImpl
virtual bool isValidNativeWindow(EGLNativeWindowType window) const = 0; virtual bool isValidNativeWindow(EGLNativeWindowType window) const = 0;
const egl::Caps &getCaps() const;
virtual std::string getVendorString() const = 0; virtual std::string getVendorString() const = 0;
const egl::Caps &getCaps() const;
typedef std::set<egl::Surface*> SurfaceSet; typedef std::set<egl::Surface*> SurfaceSet;
const SurfaceSet &getSurfaceSet() const { return mSurfaceSet; } const SurfaceSet &getSurfaceSet() const { return mSurfaceSet; }
SurfaceSet &getSurfaceSet() { return mSurfaceSet; } SurfaceSet &getSurfaceSet() { return mSurfaceSet; }
......
//
// Copyright (c) 2015 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.
//
// FenceNVImpl.h: Defines the rx::FenceNVImpl class.
#ifndef LIBANGLE_RENDERER_FENCENVIMPL_H_
#define LIBANGLE_RENDERER_FENCENVIMPL_H_
#include "libANGLE/Error.h"
#include "common/angleutils.h"
#include "angle_gl.h"
namespace rx
{
class FenceNVImpl
{
public:
FenceNVImpl() { };
virtual ~FenceNVImpl() { };
virtual gl::Error set() = 0;
virtual gl::Error test(bool flushCommandBuffer, GLboolean *outFinished) = 0;
virtual gl::Error finishFence(GLboolean *outFinished) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(FenceNVImpl);
};
}
#endif // LIBANGLE_RENDERER_FENCENVIMPL_H_
// //
// Copyright (c) 2013 The ANGLE Project Authors. All rights reserved. // Copyright (c) 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// //
// FenceImpl.h: Defines the rx::FenceNVImpl and rx::FenceSyncImpl classes. // FenceSyncImpl.h: Defines the rx::FenceSyncImpl class.
#ifndef LIBANGLE_RENDERER_FENCEIMPL_H_ #ifndef LIBANGLE_RENDERER_FENCESYNCIMPL_H_
#define LIBANGLE_RENDERER_FENCEIMPL_H_ #define LIBANGLE_RENDERER_FENCESYNCIMPL_H_
#include "libANGLE/Error.h" #include "libANGLE/Error.h"
...@@ -18,20 +18,6 @@ ...@@ -18,20 +18,6 @@
namespace rx namespace rx
{ {
class FenceNVImpl
{
public:
FenceNVImpl() { };
virtual ~FenceNVImpl() { };
virtual gl::Error set() = 0;
virtual gl::Error test(bool flushCommandBuffer, GLboolean *outFinished) = 0;
virtual gl::Error finishFence(GLboolean *outFinished) = 0;
private:
DISALLOW_COPY_AND_ASSIGN(FenceNVImpl);
};
class FenceSyncImpl class FenceSyncImpl
{ {
public: public:
...@@ -49,4 +35,4 @@ class FenceSyncImpl ...@@ -49,4 +35,4 @@ class FenceSyncImpl
} }
#endif // LIBANGLE_RENDERER_FENCEIMPL_H_ #endif // LIBANGLE_RENDERER_FENCESYNCIMPL_H_
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
// found in the LICENSE file. // found in the LICENSE file.
// //
// FramebufferImpl.h: Defines the abstract rx::DefaultAttachmentImpl class. // FramebufferImpl.h: Defines the abstract rx::FramebufferImpl class.
#ifndef LIBANGLE_RENDERER_FRAMBUFFERIMPL_H_ #ifndef LIBANGLE_RENDERER_FRAMEBUFFERIMPL_H_
#define LIBANGLE_RENDERER_FRAMBUFFERIMPL_H_ #define LIBANGLE_RENDERER_FRAMEBUFFERIMPL_H_
#include "angle_gl.h" #include "angle_gl.h"
#include "common/angleutils.h" #include "common/angleutils.h"
...@@ -24,21 +24,6 @@ struct Rectangle; ...@@ -24,21 +24,6 @@ struct Rectangle;
namespace rx namespace rx
{ {
class DefaultAttachmentImpl
{
public:
DefaultAttachmentImpl() {}
virtual ~DefaultAttachmentImpl() {};
virtual GLsizei getWidth() const = 0;
virtual GLsizei getHeight() const = 0;
virtual GLenum getInternalFormat() const = 0;
virtual GLsizei getSamples() const = 0;
private:
DISALLOW_COPY_AND_ASSIGN(DefaultAttachmentImpl);
};
class FramebufferImpl class FramebufferImpl
{ {
public: public:
...@@ -77,4 +62,4 @@ class FramebufferImpl ...@@ -77,4 +62,4 @@ class FramebufferImpl
} }
#endif // LIBANGLE_RENDERER_FRAMBUFFERIMPL_H_ #endif // LIBANGLE_RENDERER_FRAMEBUFFERIMPL_H_
...@@ -36,28 +36,6 @@ class ProgramImpl ...@@ -36,28 +36,6 @@ class ProgramImpl
ProgramImpl() { } ProgramImpl() { }
virtual ~ProgramImpl(); virtual ~ProgramImpl();
const std::vector<gl::LinkedUniform*> &getUniforms() const { return mUniforms; }
const std::vector<gl::VariableLocation> &getUniformIndices() const { return mUniformIndex; }
const std::vector<gl::UniformBlock*> &getUniformBlocks() const { return mUniformBlocks; }
const std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() const { return mTransformFeedbackLinkedVaryings; }
const sh::Attribute *getShaderAttributes() const { return mShaderAttributes; }
const SemanticIndexArray &getSemanticIndexes() const { return mSemanticIndex; }
std::vector<gl::LinkedUniform*> &getUniforms() { return mUniforms; }
std::vector<gl::VariableLocation> &getUniformIndices() { return mUniformIndex; }
std::vector<gl::UniformBlock*> &getUniformBlocks() { return mUniformBlocks; }
std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() { return mTransformFeedbackLinkedVaryings; }
sh::Attribute *getShaderAttributes() { return mShaderAttributes; }
SemanticIndexArray &getSemanticIndexes() { return mSemanticIndex; }
gl::LinkedUniform *getUniformByLocation(GLint location) const;
gl::LinkedUniform *getUniformByName(const std::string &name) const;
gl::UniformBlock *getUniformBlockByIndex(GLuint blockIndex) const;
GLint getUniformLocation(std::string name);
GLuint getUniformIndex(std::string name);
GLuint getUniformBlockIndex(std::string name) const;
virtual bool usesPointSize() const = 0; virtual bool usesPointSize() const = 0;
virtual int getShaderVersion() const = 0; virtual int getShaderVersion() const = 0;
virtual GLenum getTransformFeedbackBufferMode() const = 0; virtual GLenum getTransformFeedbackBufferMode() const = 0;
...@@ -99,8 +77,6 @@ class ProgramImpl ...@@ -99,8 +77,6 @@ class ProgramImpl
virtual void getUniformiv(GLint location, GLint *params) = 0; virtual void getUniformiv(GLint location, GLint *params) = 0;
virtual void getUniformuiv(GLint location, GLuint *params) = 0; virtual void getUniformuiv(GLint location, GLuint *params) = 0;
virtual void reset();
// TODO: The following functions are possibly only applicable to D3D backends. The should be carefully evaluated to // TODO: The following functions are possibly only applicable to D3D backends. The should be carefully evaluated to
// determine if they can be removed from this interface. // determine if they can be removed from this interface.
virtual GLint getSamplerMapping(gl::SamplerType type, unsigned int samplerIndex, const gl::Caps &caps) const = 0; virtual GLint getSamplerMapping(gl::SamplerType type, unsigned int samplerIndex, const gl::Caps &caps) const = 0;
...@@ -122,6 +98,30 @@ class ProgramImpl ...@@ -122,6 +98,30 @@ class ProgramImpl
virtual bool assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader, virtual bool assignUniformBlockRegister(gl::InfoLog &infoLog, gl::UniformBlock *uniformBlock, GLenum shader,
unsigned int registerIndex, const gl::Caps &caps) = 0; unsigned int registerIndex, const gl::Caps &caps) = 0;
const std::vector<gl::LinkedUniform*> &getUniforms() const { return mUniforms; }
const std::vector<gl::VariableLocation> &getUniformIndices() const { return mUniformIndex; }
const std::vector<gl::UniformBlock*> &getUniformBlocks() const { return mUniformBlocks; }
const std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() const { return mTransformFeedbackLinkedVaryings; }
const sh::Attribute *getShaderAttributes() const { return mShaderAttributes; }
const SemanticIndexArray &getSemanticIndexes() const { return mSemanticIndex; }
std::vector<gl::LinkedUniform*> &getUniforms() { return mUniforms; }
std::vector<gl::VariableLocation> &getUniformIndices() { return mUniformIndex; }
std::vector<gl::UniformBlock*> &getUniformBlocks() { return mUniformBlocks; }
std::vector<gl::LinkedVarying> &getTransformFeedbackLinkedVaryings() { return mTransformFeedbackLinkedVaryings; }
sh::Attribute *getShaderAttributes() { return mShaderAttributes; }
SemanticIndexArray &getSemanticIndexes() { return mSemanticIndex; }
gl::LinkedUniform *getUniformByLocation(GLint location) const;
gl::LinkedUniform *getUniformByName(const std::string &name) const;
gl::UniformBlock *getUniformBlockByIndex(GLuint blockIndex) const;
GLint getUniformLocation(std::string name);
GLuint getUniformIndex(std::string name);
GLuint getUniformBlockIndex(std::string name) const;
virtual void reset();
protected: protected:
DISALLOW_COPY_AND_ASSIGN(ProgramImpl); DISALLOW_COPY_AND_ASSIGN(ProgramImpl);
......
...@@ -106,16 +106,15 @@ class Renderer ...@@ -106,16 +106,15 @@ class Renderer
virtual bool testDeviceResettable() = 0; virtual bool testDeviceResettable() = 0;
virtual VendorID getVendorId() const = 0; virtual VendorID getVendorId() const = 0;
virtual std::string getVendorString() const = 0;
virtual std::string getRendererDescription() const = 0; virtual std::string getRendererDescription() const = 0;
// Renderer capabilities (virtual because of egl::Display) // Renderer capabilities
virtual const gl::Caps &getRendererCaps() const; const gl::Caps &getRendererCaps() const;
const gl::TextureCapsMap &getRendererTextureCaps() const; const gl::TextureCapsMap &getRendererTextureCaps() const;
virtual const gl::Extensions &getRendererExtensions() const; const gl::Extensions &getRendererExtensions() const;
const Workarounds &getWorkarounds() const; const Workarounds &getWorkarounds() const;
virtual std::string getVendorString() const = 0;
private: private:
DISALLOW_COPY_AND_ASSIGN(Renderer); DISALLOW_COPY_AND_ASSIGN(Renderer);
......
...@@ -24,10 +24,11 @@ class ShaderImpl ...@@ -24,10 +24,11 @@ class ShaderImpl
virtual ~ShaderImpl() { } virtual ~ShaderImpl() { }
virtual bool compile(gl::Compiler *compiler, const std::string &source) = 0; virtual bool compile(gl::Compiler *compiler, const std::string &source) = 0;
virtual const std::string &getInfoLog() const = 0;
virtual const std::string &getTranslatedSource() const = 0;
virtual std::string getDebugInfo() const = 0; virtual std::string getDebugInfo() const = 0;
virtual const std::string &getInfoLog() const { return mInfoLog; }
virtual const std::string &getTranslatedSource() const { return mTranslatedSource; }
const std::vector<gl::PackedVarying> &getVaryings() const { return mVaryings; } const std::vector<gl::PackedVarying> &getVaryings() const { return mVaryings; }
const std::vector<sh::Uniform> &getUniforms() const { return mUniforms; } const std::vector<sh::Uniform> &getUniforms() const { return mUniforms; }
const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mInterfaceBlocks; } const std::vector<sh::InterfaceBlock> &getInterfaceBlocks() const { return mInterfaceBlocks; }
...@@ -43,6 +44,9 @@ class ShaderImpl ...@@ -43,6 +44,9 @@ class ShaderImpl
protected: protected:
DISALLOW_COPY_AND_ASSIGN(ShaderImpl); DISALLOW_COPY_AND_ASSIGN(ShaderImpl);
std::string mInfoLog;
std::string mTranslatedSource;
std::vector<gl::PackedVarying> mVaryings; std::vector<gl::PackedVarying> mVaryings;
std::vector<sh::Uniform> mUniforms; std::vector<sh::Uniform> mUniforms;
std::vector<sh::InterfaceBlock> mInterfaceBlocks; std::vector<sh::InterfaceBlock> mInterfaceBlocks;
......
...@@ -37,13 +37,13 @@ class SurfaceImpl ...@@ -37,13 +37,13 @@ class SurfaceImpl
virtual egl::Error releaseTexImage(EGLint buffer) = 0; virtual egl::Error releaseTexImage(EGLint buffer) = 0;
virtual void setSwapInterval(EGLint interval) = 0; virtual void setSwapInterval(EGLint interval) = 0;
//TODO(jmadill): Possibly should be redesigned
virtual EGLNativeWindowType getWindowHandle() const = 0;
// width and height can change with client window resizing // width and height can change with client window resizing
EGLint getWidth() const { return mWidth; } EGLint getWidth() const { return mWidth; }
EGLint getHeight() const { return mHeight; } EGLint getHeight() const { return mHeight; }
//TODO(jmadill): Possibly should be redesigned
virtual EGLNativeWindowType getWindowHandle() const = 0;
const egl::Config *getConfig() const { return mConfig; } const egl::Config *getConfig() const { return mConfig; }
EGLint isFixedSize() const { return mFixedSize; } EGLint isFixedSize() const { return mFixedSize; }
EGLenum getFormat() const; EGLenum getFormat() const;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#ifndef LIBANGLE_RENDERER_D3D_FRAMBUFFERD3D_H_ #ifndef LIBANGLE_RENDERER_D3D_FRAMBUFFERD3D_H_
#define LIBANGLE_RENDERER_D3D_FRAMBUFFERD3D_H_ #define LIBANGLE_RENDERER_D3D_FRAMBUFFERD3D_H_
#include "libANGLE/renderer/DefaultAttachmentImpl.h"
#include "libANGLE/renderer/FramebufferImpl.h" #include "libANGLE/renderer/FramebufferImpl.h"
#include <vector> #include <vector>
......
...@@ -96,7 +96,7 @@ std::string ShaderD3D::getDebugInfo() const ...@@ -96,7 +96,7 @@ std::string ShaderD3D::getDebugInfo() const
void ShaderD3D::parseVaryings(ShHandle compiler) void ShaderD3D::parseVaryings(ShHandle compiler)
{ {
if (!mHlsl.empty()) if (!mTranslatedSource.empty())
{ {
const std::vector<sh::Varying> *varyings = ShGetVaryings(compiler); const std::vector<sh::Varying> *varyings = ShGetVaryings(compiler);
ASSERT(varyings); ASSERT(varyings);
...@@ -106,18 +106,18 @@ void ShaderD3D::parseVaryings(ShHandle compiler) ...@@ -106,18 +106,18 @@ void ShaderD3D::parseVaryings(ShHandle compiler)
mVaryings.push_back(gl::PackedVarying((*varyings)[varyingIndex])); mVaryings.push_back(gl::PackedVarying((*varyings)[varyingIndex]));
} }
mUsesMultipleRenderTargets = mHlsl.find("GL_USES_MRT") != std::string::npos; mUsesMultipleRenderTargets = mTranslatedSource.find("GL_USES_MRT") != std::string::npos;
mUsesFragColor = mHlsl.find("GL_USES_FRAG_COLOR") != std::string::npos; mUsesFragColor = mTranslatedSource.find("GL_USES_FRAG_COLOR") != std::string::npos;
mUsesFragData = mHlsl.find("GL_USES_FRAG_DATA") != std::string::npos; mUsesFragData = mTranslatedSource.find("GL_USES_FRAG_DATA") != std::string::npos;
mUsesFragCoord = mHlsl.find("GL_USES_FRAG_COORD") != std::string::npos; mUsesFragCoord = mTranslatedSource.find("GL_USES_FRAG_COORD") != std::string::npos;
mUsesFrontFacing = mHlsl.find("GL_USES_FRONT_FACING") != std::string::npos; mUsesFrontFacing = mTranslatedSource.find("GL_USES_FRONT_FACING") != std::string::npos;
mUsesPointSize = mHlsl.find("GL_USES_POINT_SIZE") != std::string::npos; mUsesPointSize = mTranslatedSource.find("GL_USES_POINT_SIZE") != std::string::npos;
mUsesPointCoord = mHlsl.find("GL_USES_POINT_COORD") != std::string::npos; mUsesPointCoord = mTranslatedSource.find("GL_USES_POINT_COORD") != std::string::npos;
mUsesDepthRange = mHlsl.find("GL_USES_DEPTH_RANGE") != std::string::npos; mUsesDepthRange = mTranslatedSource.find("GL_USES_DEPTH_RANGE") != std::string::npos;
mUsesFragDepth = mHlsl.find("GL_USES_FRAG_DEPTH") != std::string::npos; mUsesFragDepth = mTranslatedSource.find("GL_USES_FRAG_DEPTH") != std::string::npos;
mUsesDiscardRewriting = mHlsl.find("ANGLE_USES_DISCARD_REWRITING") != std::string::npos; mUsesDiscardRewriting = mTranslatedSource.find("ANGLE_USES_DISCARD_REWRITING") != std::string::npos;
mUsesNestedBreak = mHlsl.find("ANGLE_USES_NESTED_BREAK") != std::string::npos; mUsesNestedBreak = mTranslatedSource.find("ANGLE_USES_NESTED_BREAK") != std::string::npos;
mUsesDeferredInit = mHlsl.find("ANGLE_USES_DEFERRED_INIT") != std::string::npos; mUsesDeferredInit = mTranslatedSource.find("ANGLE_USES_DEFERRED_INIT") != std::string::npos;
} }
} }
...@@ -134,7 +134,7 @@ void ShaderD3D::uncompile() ...@@ -134,7 +134,7 @@ void ShaderD3D::uncompile()
{ {
// set by compileToHLSL // set by compileToHLSL
mCompilerOutputType = SH_ESSL_OUTPUT; mCompilerOutputType = SH_ESSL_OUTPUT;
mHlsl.clear(); mTranslatedSource.clear();
mInfoLog.clear(); mInfoLog.clear();
mUsesMultipleRenderTargets = false; mUsesMultipleRenderTargets = false;
...@@ -198,7 +198,7 @@ void ShaderD3D::compileToHLSL(ShHandle compiler, const std::string &source) ...@@ -198,7 +198,7 @@ void ShaderD3D::compileToHLSL(ShHandle compiler, const std::string &source)
if (result) if (result)
{ {
mHlsl = ShGetObjectCode(compiler); mTranslatedSource = ShGetObjectCode(compiler);
#ifdef _DEBUG #ifdef _DEBUG
// Prefix hlsl shader with commented out glsl shader // Prefix hlsl shader with commented out glsl shader
...@@ -218,8 +218,8 @@ void ShaderD3D::compileToHLSL(ShHandle compiler, const std::string &source) ...@@ -218,8 +218,8 @@ void ShaderD3D::compileToHLSL(ShHandle compiler, const std::string &source)
curPos = (nextLine == std::string::npos) ? std::string::npos : (nextLine + 1); curPos = (nextLine == std::string::npos) ? std::string::npos : (nextLine + 1);
} }
hlslStream << "\n\n"; hlslStream << "\n\n";
hlslStream << mHlsl; hlslStream << mTranslatedSource;
mHlsl = hlslStream.str(); mTranslatedSource = hlslStream.str();
#endif #endif
mUniforms = *GetShaderVariables(ShGetUniforms(compiler)); mUniforms = *GetShaderVariables(ShGetUniforms(compiler));
......
...@@ -32,8 +32,6 @@ class ShaderD3D : public ShaderImpl ...@@ -32,8 +32,6 @@ class ShaderD3D : public ShaderImpl
static const ShaderD3D *makeShaderD3D(const ShaderImpl *impl); static const ShaderD3D *makeShaderD3D(const ShaderImpl *impl);
// ShaderImpl implementation // ShaderImpl implementation
virtual const std::string &getInfoLog() const { return mInfoLog; }
virtual const std::string &getTranslatedSource() const { return mHlsl; }
virtual std::string getDebugInfo() const; virtual std::string getDebugInfo() const;
// D3D-specific methods // D3D-specific methods
...@@ -82,8 +80,6 @@ class ShaderD3D : public ShaderImpl ...@@ -82,8 +80,6 @@ class ShaderD3D : public ShaderImpl
bool mUsesDeferredInit; bool mUsesDeferredInit;
ShShaderOutput mCompilerOutputType; ShShaderOutput mCompilerOutputType;
std::string mHlsl;
std::string mInfoLog;
std::string mDebugInfo; std::string mDebugInfo;
std::map<std::string, unsigned int> mUniformRegisterMap; std::map<std::string, unsigned int> mUniformRegisterMap;
std::map<std::string, unsigned int> mInterfaceBlockRegisterMap; std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D11_FENCE11_H_ #ifndef LIBANGLE_RENDERER_D3D_D3D11_FENCE11_H_
#define LIBANGLE_RENDERER_D3D_D3D11_FENCE11_H_ #define LIBANGLE_RENDERER_D3D_D3D11_FENCE11_H_
#include "libANGLE/renderer/FenceImpl.h" #include "libANGLE/renderer/FenceNVImpl.h"
#include "libANGLE/renderer/FenceSyncImpl.h"
namespace rx namespace rx
{ {
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
#ifndef LIBANGLE_RENDERER_D3D_D3D9_FENCE9_H_ #ifndef LIBANGLE_RENDERER_D3D_D3D9_FENCE9_H_
#define LIBANGLE_RENDERER_D3D_D3D9_FENCE9_H_ #define LIBANGLE_RENDERER_D3D_D3D9_FENCE9_H_
#include "libANGLE/renderer/FenceImpl.h" #include "libANGLE/renderer/FenceNVImpl.h"
#include "libANGLE/renderer/FenceSyncImpl.h"
namespace rx namespace rx
{ {
......
#!/usr/bin/python
#
# Copyright (c) 2015 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.
#
# generate_new_renderer.py:
# Utility script to generate stubs for a new Renderer class.
# Usage: generate_new_renderer.py <renderer name> <renderer suffix>
# Renderer name is the folder for the renderer subdirectory
# Renderer suffix is the abbreviation to append after the class names.
#
# The script is fairly robust but may not work for all new methods or
# other unexpected features. It expects that abstract methods are all
# grouped after the public destructor or after the private
# DISALLOW_COPY_AND_ASSIGN macro.
import os
import sys
import re
import string
if len(sys.argv) < 3:
print('Usage: ' + sys.argv[0] + ' <renderer name> <renderer suffix>')
renderer_name = sys.argv[1]
renderer_suffix = sys.argv[2]
# ensure subdir exists
if not os.path.isdir(renderer_name):
os.mkdir(renderer_name)
impl_classes = [
'Buffer',
'Compiler',
'DefaultAttachment',
'Display',
'FenceNV',
'FenceSync',
'Framebuffer',
'Program',
'Query',
'Renderbuffer',
'Renderer',
'Shader',
'Surface',
'Texture',
'TransformFeedback',
'VertexArray',
]
h_file_template = """//
// Copyright 2015 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.
//
// $TypedImpl.h: Defines the class interface for $TypedImpl.
#ifndef LIBANGLE_RENDERER_${RendererNameCaps}_${TypedImplCaps}_H
#define LIBANGLE_RENDERER_${RendererNameCaps}_${TypedImplCaps}_H
#include "libANGLE/renderer/$BaseImpl.h"
namespace rx
{
class $TypedImpl : public $BaseImpl
{
public:
$TypedImpl($ConstructorParams);
~$TypedImpl() override;
$ImplMethodDeclarations
private:
DISALLOW_COPY_AND_ASSIGN($TypedImpl);
$PrivateImplMethodDeclarations};
}
#endif // LIBANGLE_RENDERER_${RendererNameCaps}_${TypedImplCaps}_H
"""
cpp_file_template = """//
// Copyright 2015 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.
//
// $TypedImpl.cpp: Implements the class methods for $TypedImpl.
#include "libANGLE/renderer/$RendererName/$TypedImpl.h"
#include "common/debug.h"
namespace rx
{
$TypedImpl::$TypedImpl($ConstructorParams)
: $BaseImpl($BaseContructorArgs)
{}
$TypedImpl::~$TypedImpl()
{}
$ImplMethodDefinitions
}
"""
def generate_impl_declaration(impl_stub):
# ensure the wrapped lines are aligned vertically
temp = re.sub(r'\n ', '\n', impl_stub)
return temp + ' override;\n'
def generate_impl_definition(impl_stub, typed_impl):
function_signature = impl_stub.strip()
# strip comments
function_signature = re.sub(r'\/\/[^\n]*\n', '', function_signature).strip()
prog = re.compile(r'^(.+[ \*\&])([^ \(\*\&]+\()')
return_value = prog.match(function_signature).group(1)
# ensure the wrapped lines are aligned vertically
spaces = ' ' * len(typed_impl)
function_signature = re.sub(r'\n ', '\n' + spaces, function_signature)
# add class scoping
function_signature = prog.sub(r'\1' + typed_impl + r'::\2', function_signature)
function_signature += '\n'
return_statement = ''
return_type = return_value.strip()
if return_type != 'void':
# specialized return values for Errors, pointers, etc
if return_type == 'gl::Error':
return_statement = ' return gl::Error(GL_INVALID_OPERATION);\n'
elif return_type == 'egl::Error':
return_statement = ' return egl::Error(EGL_BAD_ACCESS);\n'
elif return_type == 'LinkResult':
return_statement = ' return LinkResult(false, gl::Error(GL_INVALID_OPERATION));\n'
elif re.search(r'[\*\&]$', return_type):
return_statement = ' return static_cast<' + return_type + '>(0);\n'
else:
return_statement = ' return ' + return_type + '();\n'
body = '{\n' + ' UNIMPLEMENTED();\n' + return_statement +'}\n'
return '\n' + function_signature + body
def get_constructor_args(constructor):
params = re.search(r'\((.*)\)', constructor).group(1)
args = ', '.join(re.findall(r'[^\w]?(\w+)(?:\,|$)', params))
return params, args
for impl_class in impl_classes:
base_impl = impl_class
# special case for Renderer
if impl_class != 'Renderer':
base_impl += 'Impl'
typed_impl = impl_class + renderer_suffix
impl_h_file_path = base_impl + '.h'
h_file_path = os.path.join(renderer_name, typed_impl + '.h')
cpp_file_path = os.path.join(renderer_name, typed_impl + '.cpp')
impl_h_file = open(impl_h_file_path, 'r')
h_file = open(h_file_path, 'w')
cpp_file = open(cpp_file_path, 'w')
# extract impl stubs
copy = False
copy_private = False
impl_stubs = ''
private_impl_stubs = ''
constructor = base_impl + '() {}'
for line in impl_h_file:
clean_line = line.strip()
if re.search(r'[^~]' + base_impl + r'\(', clean_line):
constructor = clean_line
# begin capture when reading the destructor.
# begin capture also in the private scope (a few special cases)
# end capture when we reach a non-virtual function, or different scope.
if '~' + base_impl in clean_line:
copy = True
copy_private = False
elif 'DISALLOW_COPY_AND_ASSIGN' in clean_line:
copy = False
copy_private = True
elif ';' in clean_line and ' = 0' not in clean_line:
copy = False
copy_private = False
elif '}' in clean_line or 'protected:' in clean_line or 'private:' in clean_line:
copy = False
copy_private = False
elif copy:
impl_stubs += line
elif copy_private:
private_impl_stubs += line
impl_method_declarations = ''
impl_method_definitions = ''
private_impl_method_declarations = ''
for impl_stub in impl_stubs.split(' = 0;\n'):
# use 'virtual' to identify the strings with functions
if 'virtual' in impl_stub:
temp = re.sub(r'virtual ', '', impl_stub)
impl_method_declarations += generate_impl_declaration(temp)
impl_method_definitions += generate_impl_definition(temp, typed_impl)
for impl_stub in private_impl_stubs.split(' = 0;\n'):
# use 'virtual' to identify the strings with functions
if 'virtual' in impl_stub:
temp = re.sub(r'virtual ', '', impl_stub)
private_impl_method_declarations += generate_impl_declaration(temp)
impl_method_definitions += generate_impl_definition(temp, typed_impl)
constructor_params, base_constructor_args = get_constructor_args(constructor)
substitutions = {
'BaseImpl': base_impl,
'TypedImpl': typed_impl,
'TypedImplCaps': typed_impl.upper(),
'RendererName': renderer_name,
'RendererNameCaps': renderer_name.upper(),
'ImplMethodDeclarations': impl_method_declarations,
'ImplMethodDefinitions': impl_method_definitions,
'ConstructorParams': constructor_params,
'BaseContructorArgs': base_constructor_args,
'PrivateImplMethodDeclarations': private_impl_method_declarations,
}
h_file.write(string.Template(h_file_template).substitute(substitutions))
cpp_file.write(string.Template(cpp_file_template).substitute(substitutions))
impl_h_file.close()
h_file.close()
cpp_file.close()
...@@ -109,9 +109,11 @@ ...@@ -109,9 +109,11 @@
'libANGLE/queryconversions.h', 'libANGLE/queryconversions.h',
'libANGLE/renderer/BufferImpl.h', 'libANGLE/renderer/BufferImpl.h',
'libANGLE/renderer/CompilerImpl.h', 'libANGLE/renderer/CompilerImpl.h',
'libANGLE/renderer/DefaultAttachmentImpl.h',
'libANGLE/renderer/DisplayImpl.cpp', 'libANGLE/renderer/DisplayImpl.cpp',
'libANGLE/renderer/DisplayImpl.h', 'libANGLE/renderer/DisplayImpl.h',
'libANGLE/renderer/FenceImpl.h', 'libANGLE/renderer/FenceNVImpl.h',
'libANGLE/renderer/FenceSyncImpl.h',
'libANGLE/renderer/FramebufferImpl.h', 'libANGLE/renderer/FramebufferImpl.h',
'libANGLE/renderer/IndexRangeCache.cpp', 'libANGLE/renderer/IndexRangeCache.cpp',
'libANGLE/renderer/IndexRangeCache.h', 'libANGLE/renderer/IndexRangeCache.h',
......
...@@ -7,7 +7,8 @@ ...@@ -7,7 +7,8 @@
#include "gmock/gmock.h" #include "gmock/gmock.h"
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "libANGLE/Fence.h" #include "libANGLE/Fence.h"
#include "libANGLE/renderer/FenceImpl.h" #include "libANGLE/renderer/FenceNVImpl.h"
#include "libANGLE/renderer/FenceSyncImpl.h"
using ::testing::_; using ::testing::_;
using ::testing::Return; using ::testing::Return;
......
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