Commit 046e53e3 by Jamie Madill

Add an interm ShaderSh class.

This class logic will eventually move to the GL layer. Keep it in the Renderer layer for now for refactoring purposes. BUG=angleproject:1159 Change-Id: I91843099367f9a0293cc43ab98626bf79eb75ebf Reviewed-on: https://chromium-review.googlesource.com/299875Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 3d3d2f20
......@@ -136,7 +136,7 @@ void Shader::getTranslatedSourceWithDebugInfo(GLsizei bufSize, GLsizei *length,
void Shader::compile(Compiler *compiler)
{
mCompiled = mShader->compile(compiler, mSource);
mCompiled = mShader->compile(compiler, mSource, 0);
}
void Shader::addRef()
......
......@@ -23,7 +23,9 @@ class ShaderImpl : angle::NonCopyable
ShaderImpl() : mShaderVersion(100) {}
virtual ~ShaderImpl() { }
virtual bool compile(gl::Compiler *compiler, const std::string &source) = 0;
virtual bool compile(gl::Compiler *compiler,
const std::string &source,
int additionalOptions) = 0;
virtual std::string getDebugInfo() const = 0;
virtual const std::string &getInfoLog() const { return mInfoLog; }
......
//
// 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.
//
// ShaderSh:
// Common class representing a shader compile with ANGLE's translator.
//
#include "libANGLE/renderer/ShaderSh.h"
#include "common/utilities.h"
#include "libANGLE/Caps.h"
#include "libANGLE/Compiler.h"
namespace rx
{
namespace
{
template <typename VarT>
std::vector<VarT> GetActiveShaderVariables(const std::vector<VarT> *variableList)
{
ASSERT(variableList);
std::vector<VarT> result;
for (size_t varIndex = 0; varIndex < variableList->size(); varIndex++)
{
const VarT &var = variableList->at(varIndex);
if (var.staticUse)
{
result.push_back(var);
}
}
return result;
}
template <typename VarT>
const std::vector<VarT> &GetShaderVariables(const std::vector<VarT> *variableList)
{
ASSERT(variableList);
return *variableList;
}
// true if varying x has a higher priority in packing than y
bool CompareVarying(const sh::Varying &x, const sh::Varying &y)
{
if (x.type == y.type)
{
return x.arraySize > y.arraySize;
}
// Special case for handling structs: we sort these to the end of the list
if (x.type == GL_STRUCT_ANGLEX)
{
return false;
}
if (y.type == GL_STRUCT_ANGLEX)
{
return true;
}
return gl::VariableSortOrder(x.type) < gl::VariableSortOrder(y.type);
}
} // anonymous namespace
ShaderSh::ShaderSh(GLenum type, const gl::Limitations &rendererLimitations)
: mShaderType(type), mRendererLimitations(rendererLimitations)
{
}
ShaderSh::~ShaderSh()
{
}
bool ShaderSh::compile(gl::Compiler *compiler, const std::string &source, int additionalOptions)
{
// Reset the previous state
mActiveAttributes.clear();
mVaryings.clear();
mUniforms.clear();
mInterfaceBlocks.clear();
mActiveOutputVariables.clear();
mTranslatedSource.clear();
ShHandle compilerHandle = compiler->getCompilerHandle(mShaderType);
int compileOptions = (SH_OBJECT_CODE | SH_VARIABLES | additionalOptions);
// Some targets (eg D3D11 Feature Level 9_3 and below) do not support non-constant loop indexes
// in fragment shaders. Shader compilation will fail. To provide a better error message we can
// instruct the compiler to pre-validate.
if (mRendererLimitations.shadersRequireIndexedLoopValidation)
{
compileOptions |= SH_VALIDATE_LOOP_INDEXING;
}
const char *sourceCString = source.c_str();
bool result = ShCompile(compilerHandle, &sourceCString, 1, compileOptions);
if (!result)
{
mInfoLog = ShGetInfoLog(compilerHandle);
TRACE("\n%s", mInfoLog.c_str());
return false;
}
mTranslatedSource = ShGetObjectCode(compilerHandle);
#ifndef NDEBUG
// Prefix translated shader with commented out un-translated shader.
// Useful in diagnostics tools which capture the shader source.
std::ostringstream shaderStream;
shaderStream << "// GLSL\n";
shaderStream << "//\n";
size_t curPos = 0;
while (curPos != std::string::npos)
{
size_t nextLine = source.find("\n", curPos);
size_t len = (nextLine == std::string::npos) ? std::string::npos : (nextLine - curPos + 1);
shaderStream << "// " << source.substr(curPos, len);
curPos = (nextLine == std::string::npos) ? std::string::npos : (nextLine + 1);
}
shaderStream << "\n\n";
shaderStream << mTranslatedSource;
mTranslatedSource = shaderStream.str();
#endif
// Gather the shader information
mShaderVersion = ShGetShaderVersion(compilerHandle);
mVaryings = GetShaderVariables(ShGetVaryings(compilerHandle));
mUniforms = GetShaderVariables(ShGetUniforms(compilerHandle));
mInterfaceBlocks = GetShaderVariables(ShGetInterfaceBlocks(compilerHandle));
if (mShaderType == GL_VERTEX_SHADER)
{
mActiveAttributes = GetActiveShaderVariables(ShGetAttributes(compilerHandle));
}
else
{
ASSERT(mShaderType == GL_FRAGMENT_SHADER);
// TODO(jmadill): Figure out why we only sort in the FS, and if we need to.
std::sort(mVaryings.begin(), mVaryings.end(), CompareVarying);
mActiveOutputVariables = GetActiveShaderVariables(ShGetOutputVariables(compilerHandle));
}
ASSERT(!mTranslatedSource.empty());
return true;
}
} // namespace rx
//
// 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.
//
// ShaderSh:
// Common class representing a shader compile with ANGLE's translator.
// TODO(jmadill): Move this to the GL layer.
//
#ifndef LIBANGLE_RENDERER_SHADERSH_H_
#define LIBANGLE_RENDERER_SHADERSH_H_
#include "libANGLE/renderer/ShaderImpl.h"
namespace gl
{
struct Limitations;
}
namespace rx
{
class ShaderSh : public ShaderImpl
{
public:
ShaderSh(GLenum type, const gl::Limitations &rendererLimitations);
~ShaderSh();
bool compile(gl::Compiler *compiler, const std::string &source, int additionalOptions) override;
protected:
GLenum mShaderType;
const gl::Limitations &mRendererLimitations;
};
} // namespace rx
#endif // LIBANGLE_RENDERER_SHADERSH_H_
......@@ -22,70 +22,24 @@ const char *GetShaderTypeString(GLenum type)
{
switch (type)
{
case GL_VERTEX_SHADER:
return "VERTEX";
case GL_VERTEX_SHADER:
return "VERTEX";
case GL_FRAGMENT_SHADER:
return "FRAGMENT";
case GL_FRAGMENT_SHADER:
return "FRAGMENT";
default:
UNREACHABLE();
return "";
default:
UNREACHABLE();
return "";
}
}
// true if varying x has a higher priority in packing than y
bool CompareVarying(const sh::Varying &x, const sh::Varying &y)
{
if (x.type == y.type)
{
return x.arraySize > y.arraySize;
}
// Special case for handling structs: we sort these to the end of the list
if (x.type == GL_STRUCT_ANGLEX)
{
return false;
}
if (y.type == GL_STRUCT_ANGLEX)
{
return true;
}
return gl::VariableSortOrder(x.type) < gl::VariableSortOrder(y.type);
}
}
} // anonymous namespace
namespace rx
{
template <typename VarT>
void FilterInactiveVariables(std::vector<VarT> *variableList)
{
ASSERT(variableList);
for (size_t varIndex = 0; varIndex < variableList->size();)
{
if (!(*variableList)[varIndex].staticUse)
{
variableList->erase(variableList->begin() + varIndex);
}
else
{
varIndex++;
}
}
}
template <typename VarT>
const std::vector<VarT> *GetShaderVariables(const std::vector<VarT> *variableList)
{
ASSERT(variableList);
return variableList;
}
ShaderD3D::ShaderD3D(GLenum type, RendererD3D *renderer) : mShaderType(type), mRenderer(renderer)
ShaderD3D::ShaderD3D(GLenum type, const gl::Limitations &limitations) : ShaderSh(type, limitations)
{
uncompile();
}
......@@ -100,31 +54,6 @@ std::string ShaderD3D::getDebugInfo() const
}
void ShaderD3D::parseVaryings(ShHandle compiler)
{
if (!mTranslatedSource.empty())
{
const std::vector<sh::Varying> *varyings = ShGetVaryings(compiler);
ASSERT(varyings);
mVaryings = *varyings;
mUsesMultipleRenderTargets = mTranslatedSource.find("GL_USES_MRT") != std::string::npos;
mUsesFragColor = mTranslatedSource.find("GL_USES_FRAG_COLOR") != std::string::npos;
mUsesFragData = mTranslatedSource.find("GL_USES_FRAG_DATA") != std::string::npos;
mUsesFragCoord = mTranslatedSource.find("GL_USES_FRAG_COORD") != std::string::npos;
mUsesFrontFacing = mTranslatedSource.find("GL_USES_FRONT_FACING") != std::string::npos;
mUsesPointSize = mTranslatedSource.find("GL_USES_POINT_SIZE") != std::string::npos;
mUsesPointCoord = mTranslatedSource.find("GL_USES_POINT_COORD") != std::string::npos;
mUsesDepthRange = mTranslatedSource.find("GL_USES_DEPTH_RANGE") != std::string::npos;
mUsesFragDepth = mTranslatedSource.find("GL_USES_FRAG_DEPTH") != std::string::npos;
mUsesDiscardRewriting = mTranslatedSource.find("ANGLE_USES_DISCARD_REWRITING") != std::string::npos;
mUsesNestedBreak = mTranslatedSource.find("ANGLE_USES_NESTED_BREAK") != std::string::npos;
mUsesDeferredInit = mTranslatedSource.find("ANGLE_USES_DEFERRED_INIT") != std::string::npos;
mRequiresIEEEStrictCompiling = mTranslatedSource.find("ANGLE_REQUIRES_IEEE_STRICT_COMPILING") != std::string::npos;
}
}
// initialize/clean up previous state
void ShaderD3D::uncompile()
{
......@@ -156,121 +85,6 @@ void ShaderD3D::uncompile()
mDebugInfo.clear();
}
void ShaderD3D::compileToHLSL(ShHandle compiler, const std::string &source)
{
int compileOptions = (SH_OBJECT_CODE | SH_VARIABLES);
// D3D11 Feature Level 9_3 and below do not support non-constant loop indexers in fragment
// shaders.
// Shader compilation will fail. To provide a better error message we can instruct the
// compiler to pre-validate.
if (mRenderer->getRendererLimitations().shadersRequireIndexedLoopValidation)
{
compileOptions |= SH_VALIDATE_LOOP_INDEXING;
}
std::string sourcePath;
#if !defined (ANGLE_ENABLE_WINDOWS_STORE)
if (gl::DebugAnnotationsActive())
{
sourcePath = getTempPath();
writeFile(sourcePath.c_str(), source.c_str(), source.length());
compileOptions |= SH_LINE_DIRECTIVES;
}
#endif
int result;
if (sourcePath.empty())
{
const char* sourceStrings[] =
{
source.c_str(),
};
result = ShCompile(compiler, sourceStrings, ArraySize(sourceStrings), compileOptions);
}
else
{
const char* sourceStrings[] =
{
sourcePath.c_str(),
source.c_str(),
};
result = ShCompile(compiler, sourceStrings, ArraySize(sourceStrings), compileOptions | SH_SOURCE_PATH);
}
mShaderVersion = ShGetShaderVersion(compiler);
if (result)
{
mTranslatedSource = ShGetObjectCode(compiler);
#ifdef _DEBUG
// Prefix hlsl shader with commented out glsl shader
// Useful in diagnostics tools like pix which capture the hlsl shaders
std::ostringstream hlslStream;
hlslStream << "// GLSL\n";
hlslStream << "//\n";
size_t curPos = 0;
while (curPos != std::string::npos)
{
size_t nextLine = source.find("\n", curPos);
size_t len = (nextLine == std::string::npos) ? std::string::npos : (nextLine - curPos + 1);
hlslStream << "// " << source.substr(curPos, len);
curPos = (nextLine == std::string::npos) ? std::string::npos : (nextLine + 1);
}
hlslStream << "\n\n";
hlslStream << mTranslatedSource;
mTranslatedSource = hlslStream.str();
#endif
mUniforms = *GetShaderVariables(ShGetUniforms(compiler));
for (size_t uniformIndex = 0; uniformIndex < mUniforms.size(); uniformIndex++)
{
const sh::Uniform &uniform = mUniforms[uniformIndex];
if (uniform.staticUse && !uniform.isBuiltIn())
{
unsigned int index = static_cast<unsigned int>(-1);
bool getUniformRegisterResult = ShGetUniformRegister(compiler, uniform.name, &index);
UNUSED_ASSERTION_VARIABLE(getUniformRegisterResult);
ASSERT(getUniformRegisterResult);
mUniformRegisterMap[uniform.name] = index;
}
}
mInterfaceBlocks = *GetShaderVariables(ShGetInterfaceBlocks(compiler));
for (size_t blockIndex = 0; blockIndex < mInterfaceBlocks.size(); blockIndex++)
{
const sh::InterfaceBlock &interfaceBlock = mInterfaceBlocks[blockIndex];
if (interfaceBlock.staticUse)
{
unsigned int index = static_cast<unsigned int>(-1);
bool blockRegisterResult = ShGetInterfaceBlockRegister(compiler, interfaceBlock.name, &index);
UNUSED_ASSERTION_VARIABLE(blockRegisterResult);
ASSERT(blockRegisterResult);
mInterfaceBlockRegisterMap[interfaceBlock.name] = index;
}
}
}
else
{
mInfoLog = ShGetInfoLog(compiler);
TRACE("\n%s", mInfoLog.c_str());
}
}
void ShaderD3D::generateWorkarounds(D3DCompilerWorkarounds *workarounds) const
{
if (mUsesDiscardRewriting)
......@@ -316,32 +130,79 @@ ShShaderOutput ShaderD3D::getCompilerOutputType() const
return mCompilerOutputType;
}
bool ShaderD3D::compile(gl::Compiler *compiler, const std::string &source)
bool ShaderD3D::compile(gl::Compiler *compiler, const std::string &source, int additionalOptionsIn)
{
uncompile();
ShHandle compilerHandle = compiler->getCompilerHandle(mShaderType);
// TODO(jmadill): We shouldn't need to cache this.
mCompilerOutputType = ShGetShaderOutputType(compilerHandle);
compileToHLSL(compilerHandle, source);
int additionalOptions = additionalOptionsIn;
if (mShaderType == GL_VERTEX_SHADER)
#if !defined(ANGLE_ENABLE_WINDOWS_STORE)
std::stringstream sourceStream;
if (gl::DebugAnnotationsActive())
{
parseAttributes(compilerHandle);
std::string sourcePath = getTempPath();
writeFile(sourcePath.c_str(), source.c_str(), source.length());
additionalOptions |= SH_LINE_DIRECTIVES | SH_SOURCE_PATH;
sourceStream << sourcePath;
}
#endif
parseVaryings(compilerHandle);
sourceStream << source;
bool result = ShaderSh::compile(compiler, sourceStream.str(), additionalOptions);
if (mShaderType == GL_FRAGMENT_SHADER)
if (!result)
{
std::sort(mVaryings.begin(), mVaryings.end(), CompareVarying);
return false;
}
const std::string &hlsl = getTranslatedSource();
if (!hlsl.empty())
mUsesMultipleRenderTargets = mTranslatedSource.find("GL_USES_MRT") != std::string::npos;
mUsesFragColor = mTranslatedSource.find("GL_USES_FRAG_COLOR") != std::string::npos;
mUsesFragData = mTranslatedSource.find("GL_USES_FRAG_DATA") != std::string::npos;
mUsesFragCoord = mTranslatedSource.find("GL_USES_FRAG_COORD") != std::string::npos;
mUsesFrontFacing = mTranslatedSource.find("GL_USES_FRONT_FACING") != std::string::npos;
mUsesPointSize = mTranslatedSource.find("GL_USES_POINT_SIZE") != std::string::npos;
mUsesPointCoord = mTranslatedSource.find("GL_USES_POINT_COORD") != std::string::npos;
mUsesDepthRange = mTranslatedSource.find("GL_USES_DEPTH_RANGE") != std::string::npos;
mUsesFragDepth = mTranslatedSource.find("GL_USES_FRAG_DEPTH") != std::string::npos;
mUsesDiscardRewriting =
mTranslatedSource.find("ANGLE_USES_DISCARD_REWRITING") != std::string::npos;
mUsesNestedBreak = mTranslatedSource.find("ANGLE_USES_NESTED_BREAK") != std::string::npos;
mUsesDeferredInit = mTranslatedSource.find("ANGLE_USES_DEFERRED_INIT") != std::string::npos;
mRequiresIEEEStrictCompiling =
mTranslatedSource.find("ANGLE_REQUIRES_IEEE_STRICT_COMPILING") != std::string::npos;
for (const sh::Uniform &uniform : mUniforms)
{
if (uniform.staticUse && !uniform.isBuiltIn())
{
mActiveOutputVariables = *GetShaderVariables(ShGetOutputVariables(compilerHandle));
FilterInactiveVariables(&mActiveOutputVariables);
unsigned int index = static_cast<unsigned int>(-1);
bool getUniformRegisterResult =
ShGetUniformRegister(compilerHandle, uniform.name, &index);
UNUSED_ASSERTION_VARIABLE(getUniformRegisterResult);
ASSERT(getUniformRegisterResult);
mUniformRegisterMap[uniform.name] = index;
}
}
for (const sh::InterfaceBlock &interfaceBlock : mInterfaceBlocks)
{
if (interfaceBlock.staticUse)
{
unsigned int index = static_cast<unsigned int>(-1);
bool blockRegisterResult =
ShGetInterfaceBlockRegister(compilerHandle, interfaceBlock.name, &index);
UNUSED_ASSERTION_VARIABLE(blockRegisterResult);
ASSERT(blockRegisterResult);
mInterfaceBlockRegisterMap[interfaceBlock.name] = index;
}
}
......@@ -353,18 +214,7 @@ bool ShaderD3D::compile(gl::Compiler *compiler, const std::string &source)
#else
mDebugInfo += getTranslatedSource();
#endif
return !getTranslatedSource().empty();
return true;
}
void ShaderD3D::parseAttributes(ShHandle compiler)
{
const std::string &hlsl = getTranslatedSource();
if (!hlsl.empty())
{
mActiveAttributes = *GetShaderVariables(ShGetAttributes(compiler));
FilterInactiveVariables(&mActiveAttributes);
}
}
}
} // namespace rx
......@@ -9,9 +9,7 @@
#ifndef LIBANGLE_RENDERER_D3D_SHADERD3D_H_
#define LIBANGLE_RENDERER_D3D_SHADERD3D_H_
#include "libANGLE/renderer/d3d/WorkaroundsD3D.h"
#include "libANGLE/renderer/ShaderImpl.h"
#include "libANGLE/Shader.h"
#include "libANGLE/renderer/ShaderSh.h"
#include <map>
......@@ -19,20 +17,22 @@ namespace rx
{
class DynamicHLSL;
class RendererD3D;
struct D3DCompilerWorkarounds;
class ShaderD3D : public ShaderImpl
class ShaderD3D : public ShaderSh
{
friend class DynamicHLSL;
public:
ShaderD3D(GLenum type, RendererD3D *renderer);
ShaderD3D(GLenum type, const gl::Limitations &limitations);
virtual ~ShaderD3D();
// ShaderImpl implementation
virtual std::string getDebugInfo() const;
bool compile(gl::Compiler *compiler, const std::string &source, int additionalOptions) override;
std::string getDebugInfo() const override;
// D3D-specific methods
virtual void uncompile();
void uncompile();
unsigned int getUniformRegister(const std::string &uniformName) const;
unsigned int getInterfaceBlockRegister(const std::string &blockName) const;
void appendDebugInfo(const std::string &info) { mDebugInfo += info; }
......@@ -47,16 +47,7 @@ class ShaderD3D : public ShaderImpl
GLenum getShaderType() const;
ShShaderOutput getCompilerOutputType() const;
virtual bool compile(gl::Compiler *compiler, const std::string &source);
private:
void compileToHLSL(ShHandle compiler, const std::string &source);
void parseVaryings(ShHandle compiler);
void parseAttributes(ShHandle compiler);
GLenum mShaderType;
bool mUsesMultipleRenderTargets;
bool mUsesFragColor;
bool mUsesFragData;
......
......@@ -3005,7 +3005,7 @@ FramebufferImpl *Renderer11::createFramebuffer(const gl::Framebuffer::Data &data
ShaderImpl *Renderer11::createShader(GLenum type)
{
return new ShaderD3D(type, this);
return new ShaderD3D(type, getRendererLimitations());
}
ProgramImpl *Renderer11::createProgram(const gl::Program::Data &data)
......
......@@ -2715,7 +2715,7 @@ FramebufferImpl *Renderer9::createFramebuffer(const gl::Framebuffer::Data &data)
ShaderImpl *Renderer9::createShader(GLenum type)
{
return new ShaderD3D(type, this);
return new ShaderD3D(type, getRendererLimitations());
}
ProgramImpl *Renderer9::createProgram(const gl::Program::Data &data)
......
......@@ -244,7 +244,7 @@ CompilerImpl *RendererGL::createCompiler()
ShaderImpl *RendererGL::createShader(GLenum type)
{
return new ShaderGL(type, mFunctions);
return new ShaderGL(type, getRendererLimitations(), mFunctions);
}
ProgramImpl *RendererGL::createProgram(const gl::Program::Data &data)
......
......@@ -11,38 +11,15 @@
#include "common/debug.h"
#include "libANGLE/Compiler.h"
#include "libANGLE/renderer/gl/FunctionsGL.h"
template <typename VarT>
static std::vector<VarT> GetFilteredShaderVariables(const std::vector<VarT> *variableList)
{
ASSERT(variableList);
std::vector<VarT> result;
for (size_t varIndex = 0; varIndex < variableList->size(); varIndex++)
{
const VarT &var = variableList->at(varIndex);
if (var.staticUse)
{
result.push_back(var);
}
}
return result;
}
template <typename VarT>
static const std::vector<VarT> &GetShaderVariables(const std::vector<VarT> *variableList)
{
ASSERT(variableList);
return *variableList;
}
#include "libANGLE/renderer/gl/RendererGL.h"
namespace rx
{
ShaderGL::ShaderGL(GLenum type, const FunctionsGL *functions)
: ShaderImpl(),
mFunctions(functions),
mType(type),
mShaderID(0)
ShaderGL::ShaderGL(GLenum type,
const gl::Limitations &rendererLimitations,
const FunctionsGL *functions)
: ShaderSh(type, rendererLimitations), mFunctions(functions), mShaderID(0)
{
ASSERT(mFunctions);
}
......@@ -56,37 +33,26 @@ ShaderGL::~ShaderGL()
}
}
bool ShaderGL::compile(gl::Compiler *compiler, const std::string &source)
bool ShaderGL::compile(gl::Compiler *compiler, const std::string &source, int additionalOptionsIn)
{
// Reset the previous state
mActiveAttributes.clear();
mVaryings.clear();
mUniforms.clear();
mInterfaceBlocks.clear();
mActiveOutputVariables.clear();
if (mShaderID != 0)
{
mFunctions->deleteShader(mShaderID);
mShaderID = 0;
}
// Translate the ESSL into GLSL
ShHandle compilerHandle = compiler->getCompilerHandle(mType);
int compileOptions = (SH_OBJECT_CODE | SH_VARIABLES | SH_INIT_GL_POSITION);
const char* sourceCString = source.c_str();
if (!ShCompile(compilerHandle, &sourceCString, 1, compileOptions))
int additionalOptions = (additionalOptionsIn | SH_INIT_GL_POSITION);
if (!ShaderSh::compile(compiler, source, additionalOptions))
{
mInfoLog = ShGetInfoLog(compilerHandle);
TRACE("\n%s", mInfoLog.c_str());
return false;
}
mTranslatedSource = ShGetObjectCode(compilerHandle);
const char* translatedSourceCString = mTranslatedSource.c_str();
// Translate the ESSL into GLSL
const char *translatedSourceCString = mTranslatedSource.c_str();
// Generate a shader object and set the source
mShaderID = mFunctions->createShader(mType);
mShaderID = mFunctions->createShader(mShaderType);
mFunctions->shaderSource(mShaderID, 1, &translatedSourceCString, nullptr);
mFunctions->compileShader(mShaderID);
......@@ -111,25 +77,6 @@ bool ShaderGL::compile(gl::Compiler *compiler, const std::string &source)
return false;
}
// Gather the shader information
mShaderVersion = ShGetShaderVersion(compilerHandle);
// TODO: refactor this out, gathering of the attributes, varyings and outputs should be done
// at the gl::Shader level
if (mType == GL_VERTEX_SHADER)
{
mActiveAttributes = GetFilteredShaderVariables(ShGetAttributes(compilerHandle));
}
mVaryings = GetShaderVariables(ShGetVaryings(compilerHandle));
mUniforms = GetShaderVariables(ShGetUniforms(compilerHandle));
mInterfaceBlocks = GetShaderVariables(ShGetInterfaceBlocks(compilerHandle));
if (mType == GL_FRAGMENT_SHADER)
{
mActiveOutputVariables = GetFilteredShaderVariables(ShGetOutputVariables(compilerHandle));
}
return true;
}
......
......@@ -9,20 +9,20 @@
#ifndef LIBANGLE_RENDERER_GL_SHADERGL_H_
#define LIBANGLE_RENDERER_GL_SHADERGL_H_
#include "libANGLE/renderer/ShaderImpl.h"
#include "libANGLE/renderer/ShaderSh.h"
namespace rx
{
class FunctionsGL;
class RendererGL;
class ShaderGL : public ShaderImpl
class ShaderGL : public ShaderSh
{
public:
ShaderGL(GLenum type, const FunctionsGL *functions);
ShaderGL(GLenum type, const gl::Limitations &rendererLimitations, const FunctionsGL *functions);
~ShaderGL() override;
bool compile(gl::Compiler *compiler, const std::string &source) override;
bool compile(gl::Compiler *compiler, const std::string &source, int additionalOptions) override;
std::string getDebugInfo() const override;
GLuint getShaderID() const;
......@@ -30,7 +30,6 @@ class ShaderGL : public ShaderImpl
private:
const FunctionsGL *mFunctions;
GLenum mType;
GLuint mShaderID;
};
......
......@@ -147,6 +147,8 @@
'libANGLE/renderer/Renderer.cpp',
'libANGLE/renderer/Renderer.h',
'libANGLE/renderer/ShaderImpl.h',
'libANGLE/renderer/ShaderSh.cpp',
'libANGLE/renderer/ShaderSh.h',
'libANGLE/renderer/SurfaceImpl.cpp',
'libANGLE/renderer/SurfaceImpl.h',
'libANGLE/renderer/TextureImpl.h',
......
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