Commit 334d615f by Jamie Madill

Fix up the style in DynamicHLSL a bit.

Use std::stringstream when possible, and use Context's caps instead of the Renderer's. BUG=angleproject:754 Change-Id: I2dc773709bbd612ab7ea372a358337c0a81869a3 Reviewed-on: https://chromium-review.googlesource.com/307872Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Tested-by: 's avatarJamie Madill <jmadill@chromium.org>
parent b2e2425a
......@@ -74,26 +74,32 @@ class DynamicHLSL : angle::NonCopyable
public:
explicit DynamicHLSL(RendererD3D *const renderer);
int packVaryings(gl::InfoLog &infoLog,
int packVaryings(const gl::Caps &caps,
gl::InfoLog &infoLog,
std::vector<PackedVarying> *packedVaryings,
const std::vector<std::string> &transformFeedbackVaryings);
std::string generateVertexShaderForInputLayout(const std::string &sourceShader,
const gl::InputLayout &inputLayout,
const std::vector<sh::Attribute> &shaderAttributes) const;
std::string generatePixelShaderForOutputSignature(const std::string &sourceShader, const std::vector<PixelShaderOutputVariable> &outputVariables,
bool usesFragDepth, const std::vector<GLenum> &outputLayout) const;
std::string generateVertexShaderForInputLayout(
const std::string &sourceShader,
const gl::InputLayout &inputLayout,
const std::vector<sh::Attribute> &shaderAttributes) const;
std::string generatePixelShaderForOutputSignature(
const std::string &sourceShader,
const std::vector<PixelShaderOutputVariable> &outputVariables,
bool usesFragDepth,
const std::vector<GLenum> &outputLayout) const;
bool generateShaderLinkHLSL(const gl::Data &data,
const gl::Program::Data &programData,
gl::InfoLog &infoLog,
int registers,
std::string &pixelHLSL,
std::string &vertexHLSL,
std::string *pixelHLSL,
std::string *vertexHLSL,
const std::vector<PackedVarying> &packedVaryings,
std::vector<gl::LinkedVarying> *linkedVaryings,
std::vector<PixelShaderOutputVariable> *outPixelShaderKey,
bool *outUsesFragDepth) const;
std::string generateGeometryShaderHLSL(int registers,
std::string generateGeometryShaderHLSL(const gl::Data &data,
int registers,
const ShaderD3D *fragmentShader,
const std::vector<PackedVarying> &packedVaryings) const;
......@@ -103,16 +109,24 @@ class DynamicHLSL : angle::NonCopyable
struct SemanticInfo;
std::string getVaryingSemantic(bool pointSize) const;
SemanticInfo getSemanticInfo(int startRegisters, bool position, bool fragCoord, bool pointCoord,
bool pointSize, bool pixelShader) const;
std::string generateVaryingLinkHLSL(const SemanticInfo &info, const std::string &varyingHLSL) const;
std::string generateVaryingHLSL(const std::vector<PackedVarying> &varyings,
SemanticInfo getSemanticInfo(int startRegisters,
bool position,
bool fragCoord,
bool pointCoord,
bool pointSize,
bool pixelShader) const;
std::string generateVaryingLinkHLSL(const SemanticInfo &info,
const std::string &varyingHLSL) const;
std::string generateVaryingHLSL(const gl::Caps &caps,
const std::vector<PackedVarying> &varyings,
bool shaderUsesPointSize) const;
void storeUserLinkedVaryings(const std::vector<PackedVarying> &packedVaryings,
bool shaderUsesPointSize,
std::vector<gl::LinkedVarying> *linkedVaryings) const;
void storeBuiltinLinkedVaryings(const SemanticInfo &info, std::vector<gl::LinkedVarying> *linkedVaryings) const;
std::string generatePointSpriteHLSL(int registers,
void storeBuiltinLinkedVaryings(const SemanticInfo &info,
std::vector<gl::LinkedVarying> *linkedVaryings) const;
std::string generatePointSpriteHLSL(const gl::Data &data,
int registers,
const ShaderD3D *fragmentShader,
const std::vector<PackedVarying> &packedVaryings) const;
......@@ -122,7 +136,6 @@ class DynamicHLSL : angle::NonCopyable
std::string generateAttributeConversionHLSL(gl::VertexFormatType vertexFormatType,
const sh::ShaderVariable &shaderAttrib) const;
};
}
#endif // LIBANGLE_RENDERER_D3D_DYNAMICHLSL_H_
#endif // LIBANGLE_RENDERER_D3D_DYNAMICHLSL_H_
......@@ -289,7 +289,8 @@ gl::Error HLSLCompiler::compileToBinary(gl::InfoLog &infoLog, const std::string
return gl::Error(GL_OUT_OF_MEMORY, "HLSL compiler had an unexpected failure, result: 0x%X.", result);
}
infoLog << "Warning: D3D shader compilation failed with " << configs[i].name << " flags.";
infoLog << "Warning: D3D shader compilation failed with " << configs[i].name << " flags. ("
<< profile << ")";
if (i + 1 < configs.size())
{
......
......@@ -90,7 +90,9 @@ class ProgramD3D : public ProgramImpl
const std::vector<PixelShaderOutputVariable> &getPixelShaderKey() { return mPixelShaderKey; }
GLint getSamplerMapping(gl::SamplerType type, unsigned int samplerIndex, const gl::Caps &caps) const;
GLint getSamplerMapping(gl::SamplerType type,
unsigned int samplerIndex,
const gl::Caps &caps) const;
GLenum getSamplerTextureType(gl::SamplerType type, unsigned int samplerIndex) const;
GLint getUsedSamplerRange(gl::SamplerType type) const;
void updateSamplerMapping();
......@@ -103,9 +105,14 @@ class ProgramD3D : public ProgramImpl
LinkResult load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream);
gl::Error save(gl::BinaryOutputStream *stream);
gl::Error getPixelExecutableForFramebuffer(const gl::Framebuffer *fbo, ShaderExecutableD3D **outExectuable);
gl::Error getPixelExecutableForOutputLayout(const std::vector<GLenum> &outputLayout, ShaderExecutableD3D **outExectuable, gl::InfoLog *infoLog);
gl::Error getVertexExecutableForInputLayout(const gl::InputLayout &inputLayout, ShaderExecutableD3D **outExectuable, gl::InfoLog *infoLog);
gl::Error getPixelExecutableForFramebuffer(const gl::Framebuffer *fbo,
ShaderExecutableD3D **outExectuable);
gl::Error getPixelExecutableForOutputLayout(const std::vector<GLenum> &outputLayout,
ShaderExecutableD3D **outExectuable,
gl::InfoLog *infoLog);
gl::Error getVertexExecutableForInputLayout(const gl::InputLayout &inputLayout,
ShaderExecutableD3D **outExectuable,
gl::InfoLog *infoLog);
ShaderExecutableD3D *getGeometryExecutable() const { return mGeometryExecutable; }
LinkResult link(const gl::Data &data, gl::InfoLog &infoLog) override;
......@@ -132,15 +139,42 @@ class ProgramD3D : public ProgramImpl
void setUniform2uiv(GLint location, GLsizei count, const GLuint *v);
void setUniform3uiv(GLint location, GLsizei count, const GLuint *v);
void setUniform4uiv(GLint location, GLsizei count, const GLuint *v);
void setUniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void setUniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void setUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void setUniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void setUniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void setUniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void setUniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void setUniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void setUniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
void setUniformMatrix2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
void setUniformMatrix3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
void setUniformMatrix4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
void setUniformMatrix2x3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
void setUniformMatrix3x2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
void setUniformMatrix2x4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
void setUniformMatrix4x2fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
void setUniformMatrix3x4fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
void setUniformMatrix4x3fv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value);
void setUniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) override;
......@@ -149,9 +183,10 @@ class ProgramD3D : public ProgramImpl
unsigned int getSerial() const;
void sortAttributesByLayout(const std::vector<TranslatedAttribute> &unsortedAttributes,
int sortedSemanticIndicesOut[gl::MAX_VERTEX_ATTRIBS],
const rx::TranslatedAttribute *sortedAttributesOut[gl::MAX_VERTEX_ATTRIBS]) const;
void sortAttributesByLayout(
const std::vector<TranslatedAttribute> &unsortedAttributes,
int sortedSemanticIndicesOut[gl::MAX_VERTEX_ATTRIBS],
const rx::TranslatedAttribute *sortedAttributesOut[gl::MAX_VERTEX_ATTRIBS]) const;
const SemanticIndexArray &getSemanticIndexes() const { return mSemanticIndexes; }
const SemanticIndexArray &getAttributesByLayout() const { return mAttributesByLayout; }
......@@ -187,10 +222,14 @@ class ProgramD3D : public ProgramImpl
class PixelExecutable
{
public:
PixelExecutable(const std::vector<GLenum> &outputSignature, ShaderExecutableD3D *shaderExecutable);
PixelExecutable(const std::vector<GLenum> &outputSignature,
ShaderExecutableD3D *shaderExecutable);
~PixelExecutable();
bool matchesSignature(const std::vector<GLenum> &signature) const { return mOutputSignature == signature; }
bool matchesSignature(const std::vector<GLenum> &signature) const
{
return mOutputSignature == signature;
}
const std::vector<GLenum> &outputSignature() const { return mOutputSignature; }
ShaderExecutableD3D *shaderExecutable() const { return mShaderExecutable; }
......@@ -230,12 +269,17 @@ class ProgramD3D : public ProgramImpl
GLuint *outUsedRange);
template <typename T>
void setUniform(GLint location, GLsizei count, const T* v, GLenum targetUniformType);
void setUniform(GLint location, GLsizei count, const T *v, GLenum targetUniformType);
template <int cols, int rows>
void setUniformMatrixfv(GLint location, GLsizei count, GLboolean transpose, const GLfloat *value, GLenum targetUniformType);
LinkResult compileProgramExecutables(gl::InfoLog &infoLog,
void setUniformMatrixfv(GLint location,
GLsizei count,
GLboolean transpose,
const GLfloat *value,
GLenum targetUniformType);
LinkResult compileProgramExecutables(const gl::Data &data,
gl::InfoLog &infoLog,
int registers,
const std::vector<PackedVarying> &packedVaryings);
......@@ -301,7 +345,6 @@ class ProgramD3D : public ProgramImpl
static unsigned int issueSerial();
static unsigned int mCurrentSerial;
};
}
#endif // LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_
#endif // LIBANGLE_RENDERER_D3D_PROGRAMD3D_H_
......@@ -21,8 +21,6 @@ struct D3DCompilerWorkarounds;
class ShaderD3D : public ShaderImpl
{
friend class DynamicHLSL;
public:
ShaderD3D(const gl::Shader::Data &data);
virtual ~ShaderD3D();
......@@ -40,10 +38,17 @@ class ShaderD3D : public ShaderImpl
void appendDebugInfo(const std::string &info) { mDebugInfo += info; }
void generateWorkarounds(D3DCompilerWorkarounds *workarounds) const;
bool usesDepthRange() const { return mUsesDepthRange; }
bool usesMultipleRenderTargets() const { return mUsesMultipleRenderTargets; }
bool usesFragColor() const { return mUsesFragColor; }
bool usesFragData() const { return mUsesFragData; }
bool usesFragCoord() const { return mUsesFragCoord; }
bool usesFrontFacing() const { return mUsesFrontFacing; }
bool usesPointSize() const { return mUsesPointSize; }
bool usesPointCoord() const { return mUsesPointCoord; }
bool usesDepthRange() const { return mUsesDepthRange; }
bool usesFragDepth() const { return mUsesFragDepth; }
bool usesDeferredInit() const { return mUsesDeferredInit; }
bool usesFrontFacing() const { return mUsesFrontFacing; }
ShShaderOutput getCompilerOutputType() const;
......@@ -67,7 +72,6 @@ class ShaderD3D : public ShaderImpl
std::map<std::string, unsigned int> mUniformRegisterMap;
std::map<std::string, unsigned int> mInterfaceBlockRegisterMap;
};
}
#endif // LIBANGLE_RENDERER_D3D_SHADERD3D_H_
#endif // LIBANGLE_RENDERER_D3D_SHADERD3D_H_
......@@ -381,6 +381,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig5650Support)
ASSERT_EGL_SUCCESS();
GLuint program = createProgram();
ASSERT_NE(0u, program);
drawWithProgram(program);
EXPECT_GL_NO_ERROR();
glDeleteProgram(program);
......@@ -422,6 +423,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig4444Support)
ASSERT_EGL_SUCCESS();
GLuint program = createProgram();
ASSERT_NE(0u, program);
drawWithProgram(program);
EXPECT_GL_NO_ERROR();
glDeleteProgram(program);
......@@ -463,6 +465,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig5551Support)
ASSERT_EGL_SUCCESS();
GLuint program = createProgram();
ASSERT_NE(0u, program);
drawWithProgram(program);
EXPECT_GL_NO_ERROR();
glDeleteProgram(program);
......@@ -504,6 +507,7 @@ TEST_F(EGLSurfaceTest, CreateWithEGLConfig8880Support)
ASSERT_EGL_SUCCESS();
GLuint program = createProgram();
ASSERT_NE(0u, program);
drawWithProgram(program);
EXPECT_GL_NO_ERROR();
glDeleteProgram(program);
......
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