Commit 5f562735 by Jamie Madill

Moved all HLSL-related code from ProgramBinary to DynamicHLSL.

DynamicHLSL encapsulates all HLSL generation we need outside the the shader translator, such as for linking between input and output stages and point sprite geometry shaders. BUG=angle:560 Change-Id: Ib5079aa102000a7c37b166bcbe26b09cc82f8932 Reviewed-on: https://chromium-review.googlesource.com/185191Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent e8bc3193
......@@ -140,16 +140,17 @@
<ClInclude Include="..\..\src\libGLESv2\Query.h"/>
<ClInclude Include="..\..\src\libGLESv2\ResourceManager.h"/>
<ClInclude Include="..\..\src\libGLESv2\Texture.h"/>
<ClInclude Include="..\..\src\libGLESv2\DynamicHLSL.h"/>
<ClInclude Include="..\..\src\libGLESv2\ProgramBinary.h"/>
<ClInclude Include="..\..\src\libGLESv2\Buffer.h"/>
<ClInclude Include="..\..\src\libGLESv2\validationES2.h"/>
<ClInclude Include="..\..\src\libGLESv2\Fence.h"/>
<ClInclude Include="..\..\src\libGLESv2\angletypes.h"/>
<ClInclude Include="..\..\src\libGLESv2\VertexArray.h"/>
<ClInclude Include="..\..\src\libGLESv2\Uniform.h"/>
<ClInclude Include="..\..\src\libGLESv2\constants.h"/>
<ClInclude Include="..\..\src\libGLESv2\main.h"/>
<ClInclude Include="..\..\src\libGLESv2\Framebuffer.h"/>
<ClInclude Include="..\..\src\libGLESv2\VertexArray.h"/>
<ClInclude Include="..\..\src\libGLESv2\angletypes.h"/>
<ClInclude Include="..\..\src\libGLESv2\formatutils.h"/>
<ClInclude Include="..\..\src\libGLESv2\RenderbufferProxySet.h"/>
<ClInclude Include="..\..\src\libGLESv2\validationES.h"/>
......@@ -288,6 +289,7 @@
<ClCompile Include="..\..\src\libGLESv2\libGLESv2.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\validationES2.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\precompiled.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\DynamicHLSL.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\queryconversions.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\HandleAllocator.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\formatutils.cpp"/>
......@@ -353,8 +355,8 @@
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\TextureStorage9.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\Fence9.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\Blit9.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\SwapChain9.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\VertexBuffer9.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\SwapChain9.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\formatutils9.cpp"/>
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\Query9.cpp"/>
<ClCompile Include="..\..\src\common\event_tracer.cpp"/>
......
......@@ -81,6 +81,9 @@
<ClCompile Include="..\..\src\libGLESv2\precompiled.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClCompile Include="..\..\src\libGLESv2\DynamicHLSL.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\queryconversions.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
......@@ -135,6 +138,9 @@
<ClCompile Include="..\..\src\libGLESv2\Context.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\DynamicHLSL.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClCompile Include="..\..\src\libGLESv2\Fence.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
......@@ -162,15 +168,15 @@
<ClCompile Include="..\..\src\libGLESv2\Renderbuffer.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\angletypes.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClInclude Include="..\..\src\libGLESv2\Uniform.h">
<ClInclude Include="..\..\src\libGLESv2\VertexArray.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClCompile Include="..\..\src\libGLESv2\Query.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\Uniform.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClCompile Include="..\..\src\libGLESv2\Buffer.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
......@@ -201,6 +207,9 @@
<None Include="..\..\src\libGLESv2\libGLESv2.def">
<Filter>src\libGLESv2</Filter>
</None>
<ClInclude Include="..\..\src\libGLESv2\angletypes.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClCompile Include="..\..\src\libGLESv2\validationES3.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
......@@ -216,9 +225,6 @@
<ClCompile Include="..\..\src\libGLESv2\Sampler.cpp">
<Filter>src\libGLESv2</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\VertexArray.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
<ClInclude Include="..\..\src\libGLESv2\formatutils.h">
<Filter>src\libGLESv2</Filter>
</ClInclude>
......@@ -678,15 +684,15 @@
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\Blit9.cpp">
<Filter>src\libGLESv2\renderer\d3d9</Filter>
</ClCompile>
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\VertexBuffer9.cpp">
<Filter>src\libGLESv2\renderer\d3d9</Filter>
</ClCompile>
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\SwapChain9.cpp">
<Filter>src\libGLESv2\renderer\d3d9</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\renderer\d3d9\BufferStorage9.h">
<Filter>src\libGLESv2\renderer\d3d9</Filter>
</ClInclude>
<ClCompile Include="..\..\src\libGLESv2\renderer\d3d9\VertexBuffer9.cpp">
<Filter>src\libGLESv2\renderer\d3d9</Filter>
</ClCompile>
<ClInclude Include="..\..\src\libGLESv2\renderer\d3d9\Renderer9.h">
<Filter>src\libGLESv2\renderer\d3d9</Filter>
</ClInclude>
......
//
// 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.
//
// DynamicHLSL.h: Interface for link and run-time HLSL generation
//
#ifndef LIBGLESV2_DYNAMIC_HLSL_H_
#define LIBGLESV2_DYNAMIC_HLSL_H_
#include "common/angleutils.h"
namespace sh
{
struct ShaderVariable;
}
namespace rx
{
class Renderer;
}
namespace gl
{
class InfoLog;
class FragmentShader;
class VertexShader;
struct VariableLocation;
class DynamicHLSL
{
public:
explicit DynamicHLSL(rx::Renderer *const renderer);
int packVaryings(InfoLog &infoLog, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader);
bool generateShaderLinkHLSL(InfoLog &infoLog, int registers, const sh::ShaderVariable *packing[][4],
std::string& pixelHLSL, std::string& vertexHLSL,
FragmentShader *fragmentShader, VertexShader *vertexShader,
std::map<int, VariableLocation> *programOutputVars) const;
std::string generateGeometryShaderHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
private:
DISALLOW_COPY_AND_ASSIGN(DynamicHLSL);
rx::Renderer *const mRenderer;
std::string generateVaryingHLSL(FragmentShader *fragmentShader, const std::string &varyingSemantic) const;
void defineOutputVariables(FragmentShader *fragmentShader, std::map<int, VariableLocation> *programOutputVars) const;
std::string generatePointSpriteHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
// Prepend an underscore
static std::string decorateAttribute(const std::string &name);
};
// Utility method shared between ProgramBinary and DynamicHLSL
std::string ArrayString(unsigned int i);
}
#endif // LIBGLESV2_DYNAMIC_HLSL_H_
......@@ -32,6 +32,7 @@ class ShaderExecutable;
class Renderer;
struct TranslatedAttribute;
class UniformStorage;
class DynamicHLSL;
}
namespace gl
......@@ -144,8 +145,6 @@ class ProgramBinary : public RefCountObject
void initAttributesByLayout();
void sortAttributesByLayout(rx::TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const;
static std::string decorateAttribute(const std::string &name); // Prepend an underscore
const UniformArray &getUniforms() const { return mUniforms; }
const rx::UniformStorage &getVertexUniformStorage() const { return *mVertexUniformStorage; }
const rx::UniformStorage &getFragmentUniformStorage() const { return *mFragmentUniformStorage; }
......@@ -153,12 +152,7 @@ class ProgramBinary : public RefCountObject
private:
DISALLOW_COPY_AND_ASSIGN(ProgramBinary);
int packVaryings(InfoLog &infoLog, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader);
bool linkVaryings(InfoLog &infoLog, int registers, const sh::ShaderVariable *packing[][4],
std::string& pixelHLSL, std::string& vertexHLSL,
FragmentShader *fragmentShader, VertexShader *vertexShader);
std::string generateVaryingHLSL(FragmentShader *fragmentShader, const std::string &varyingSemantic) const;
bool linkVaryings(InfoLog &infoLog, FragmentShader *fragmentShader, VertexShader *vertexShader);
bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, FragmentShader *fragmentShader, VertexShader *vertexShader);
typedef sh::BlockMemberInfoArray::const_iterator BlockInfoItr;
......@@ -180,9 +174,6 @@ class ProgramBinary : public RefCountObject
void defineOutputVariables(FragmentShader *fragmentShader);
void initializeUniformStorage();
std::string generateGeometryShaderHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
std::string generatePointSpriteHLSL(int registers, const sh::ShaderVariable *packing[][4], FragmentShader *fragmentShader, VertexShader *vertexShader) const;
template <typename T>
bool setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType);
......@@ -195,6 +186,7 @@ class ProgramBinary : public RefCountObject
static TextureType getTextureType(GLenum samplerType, InfoLog &infoLog);
rx::Renderer *const mRenderer;
DynamicHLSL *mDynamicHLSL;
rx::ShaderExecutable *mPixelExecutable;
rx::ShaderExecutable *mVertexExecutable;
......@@ -222,10 +214,8 @@ class ProgramBinary : public RefCountObject
UniformArray mUniforms;
UniformBlockArray mUniformBlocks;
typedef std::vector<VariableLocation> UniformIndex;
UniformIndex mUniformIndex;
typedef std::map<int, VariableLocation> ShaderVariableIndex;
ShaderVariableIndex mOutputVariables;
std::vector<VariableLocation> mUniformIndex;
std::map<int, VariableLocation> mOutputVariables;
rx::UniformStorage *mVertexUniformStorage;
rx::UniformStorage *mFragmentUniformStorage;
......@@ -236,6 +226,7 @@ class ProgramBinary : public RefCountObject
static unsigned int issueSerial();
static unsigned int mCurrentSerial;
};
}
#endif // LIBGLESV2_PROGRAM_BINARY_H_
......@@ -125,6 +125,11 @@ const sh::ActiveInterfaceBlocks &Shader::getInterfaceBlocks() const
return mActiveInterfaceBlocks;
}
std::vector<sh::Varying> &Shader::getVaryings()
{
return mVaryings;
}
bool Shader::isCompiled() const
{
return !mHlsl.empty();
......@@ -368,6 +373,16 @@ void Shader::compileToHLSL(void *compiler)
}
}
rx::D3DWorkaroundType Shader::getD3DWorkarounds() const
{
if (mUsesDiscardRewriting)
{
return rx::ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER;
}
return rx::ANGLE_D3D_WORKAROUND_NONE;
}
// [OpenGL ES SL 3.00.4] Section 11 p. 120
// Vertex Outs/Fragment Ins packing priorities
static const GLenum varyingPriorityList[] =
......
......@@ -21,6 +21,7 @@
#include "compiler/translator/ShaderVariable.h"
#include "common/angleutils.h"
#include "libGLESv2/angletypes.h"
namespace rx
{
......@@ -33,7 +34,7 @@ class ResourceManager;
class Shader
{
friend class ProgramBinary;
friend class DynamicHLSL;
public:
Shader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle);
......@@ -53,6 +54,7 @@ class Shader
void getTranslatedSource(GLsizei bufSize, GLsizei *length, char *buffer) const;
const std::vector<sh::Uniform> &getUniforms() const;
const sh::ActiveInterfaceBlocks &getInterfaceBlocks() const;
std::vector<sh::Varying> &getVaryings();
virtual void compile() = 0;
virtual void uncompile();
......@@ -65,12 +67,16 @@ class Shader
bool isFlaggedForDeletion() const;
void flagForDeletion();
int getShaderVersion() const;
void resetVaryingsRegisterAssignment();
static void releaseCompiler();
bool usesDepthRange() const { return mUsesDepthRange; }
bool usesPointSize() const { return mUsesPointSize; }
rx::D3DWorkaroundType getD3DWorkarounds() const;
protected:
void parseVaryings(void *compiler);
void resetVaryingsRegisterAssignment();
void compileToHLSL(void *compiler);
......@@ -117,7 +123,7 @@ class Shader
class VertexShader : public Shader
{
friend class ProgramBinary;
friend class DynamicHLSL;
public:
VertexShader(ResourceManager *manager, const rx::Renderer *renderer, GLuint handle);
......@@ -129,6 +135,8 @@ class VertexShader : public Shader
virtual void uncompile();
int getSemanticIndex(const std::string &attributeName);
const std::vector<sh::Attribute> &activeAttributes() const { return mActiveAttributes; }
private:
DISALLOW_COPY_AND_ASSIGN(VertexShader);
......
......@@ -253,6 +253,12 @@ enum VertexConversionType
VERTEX_CONVERT_BOTH = 3
};
enum D3DWorkaroundType
{
ANGLE_D3D_WORKAROUND_NONE,
ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER
};
}
#endif // LIBGLESV2_ANGLETYPES_H_
......@@ -97,12 +97,6 @@ enum ShaderType
SHADER_GEOMETRY
};
enum D3DWorkaroundType
{
ANGLE_D3D_WORKAROUND_NONE,
ANGLE_D3D_WORKAROUND_SM3_OPTIMIZER
};
class Renderer
{
public:
......
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