Commit 7dd2e10d by Geoff Lang

Merge the ProgramBinary class into Program.

BUG=angle:731 Change-Id: I2ee97155841dc62f04bb71c1f2035d210fd3883c Reviewed-on: https://chromium-review.googlesource.com/232694Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 21329414
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/ProgramBinary.h"
#include "libANGLE/Query.h" #include "libANGLE/Query.h"
#include "libANGLE/ResourceManager.h" #include "libANGLE/ResourceManager.h"
#include "libANGLE/Sampler.h" #include "libANGLE/Sampler.h"
...@@ -123,17 +122,7 @@ Context::Context(int clientVersion, const Context *shareContext, rx::Renderer *r ...@@ -123,17 +122,7 @@ Context::Context(int clientVersion, const Context *shareContext, rx::Renderer *r
Context::~Context() Context::~Context()
{ {
GLuint currentProgram = mState.getCurrentProgramId(); mState.reset();
if (currentProgram != 0)
{
Program *programObject = mResourceManager->getProgram(currentProgram);
if (programObject)
{
programObject->release();
}
currentProgram = 0;
}
mState.setCurrentProgram(0, NULL);
while (!mFramebufferMap.empty()) while (!mFramebufferMap.empty())
{ {
...@@ -623,58 +612,7 @@ void Context::bindPixelUnpackBuffer(GLuint buffer) ...@@ -623,58 +612,7 @@ void Context::bindPixelUnpackBuffer(GLuint buffer)
void Context::useProgram(GLuint program) void Context::useProgram(GLuint program)
{ {
GLuint priorProgramId = mState.getCurrentProgramId(); mState.setProgram(getProgram(program));
Program *priorProgram = mResourceManager->getProgram(priorProgramId);
if (priorProgramId != program)
{
mState.setCurrentProgram(program, mResourceManager->getProgram(program));
if (priorProgram)
{
priorProgram->release();
}
}
}
Error Context::linkProgram(GLuint program)
{
Program *programObject = mResourceManager->getProgram(program);
Error error = programObject->link(getData());
if (error.isError())
{
return error;
}
// if the current program was relinked successfully we
// need to install the new executables
if (programObject->isLinked() && program == mState.getCurrentProgramId())
{
mState.setCurrentProgramBinary(programObject->getProgramBinary());
}
return Error(GL_NO_ERROR);
}
Error Context::setProgramBinary(GLuint program, GLenum binaryFormat, const void *binary, GLint length)
{
Program *programObject = mResourceManager->getProgram(program);
Error error = programObject->setProgramBinary(binaryFormat, binary, length);
if (error.isError())
{
return error;
}
// if the current program was reloaded successfully we
// need to install the new executables
if (programObject->isLinked() && program == mState.getCurrentProgramId())
{
mState.setCurrentProgramBinary(programObject->getProgramBinary());
}
return Error(GL_NO_ERROR);
} }
void Context::bindTransformFeedback(GLuint transformFeedback) void Context::bindTransformFeedback(GLuint transformFeedback)
......
...@@ -43,7 +43,6 @@ namespace gl ...@@ -43,7 +43,6 @@ namespace gl
{ {
class Shader; class Shader;
class Program; class Program;
class ProgramBinary;
class Texture; class Texture;
class Texture2D; class Texture2D;
class TextureCubeMap; class TextureCubeMap;
...@@ -126,8 +125,6 @@ class ANGLE_EXPORT Context ...@@ -126,8 +125,6 @@ class ANGLE_EXPORT Context
void bindPixelPackBuffer(GLuint buffer); void bindPixelPackBuffer(GLuint buffer);
void bindPixelUnpackBuffer(GLuint buffer); void bindPixelUnpackBuffer(GLuint buffer);
void useProgram(GLuint program); void useProgram(GLuint program);
Error linkProgram(GLuint program);
Error setProgramBinary(GLuint program, GLenum binaryFormat, const void *binary, GLint length);
void bindTransformFeedback(GLuint transformFeedback); void bindTransformFeedback(GLuint transformFeedback);
Error beginQuery(GLenum target, GLuint query); Error beginQuery(GLenum target, GLuint query);
......
//
// Copyright (c) 2002-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.
//
// Program.h: Defines the gl::Program class. Implements GL program objects
// and related functionality. [OpenGL ES 2.0.24] section 2.10.3 page 28.
#ifndef LIBANGLE_PROGRAM_BINARY_H_
#define LIBANGLE_PROGRAM_BINARY_H_
#include "common/mathutil.h"
#include "libANGLE/angletypes.h"
#include "libANGLE/RefCountObject.h"
#include "libANGLE/Uniform.h"
#include "libANGLE/Shader.h"
#include "libANGLE/Constants.h"
#include "libANGLE/renderer/d3d/VertexDataManager.h"
#include "libANGLE/renderer/d3d/DynamicHLSL.h"
#include "libANGLE/export.h"
#include "angle_gl.h"
#include <string>
#include <vector>
namespace sh
{
class HLSLBlockEncoder;
}
#include <GLES3/gl3.h>
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <string>
#include <vector>
namespace rx
{
class ShaderExecutable;
struct TranslatedAttribute;
class UniformStorage;
class ProgramImpl;
}
namespace gl
{
struct Caps;
class Shader;
class InfoLog;
class AttributeBindings;
class Buffer;
class Framebuffer;
struct Data;
// Struct used for correlating uniforms/elements of uniform arrays to handles
struct VariableLocation
{
VariableLocation()
{
}
VariableLocation(const std::string &name, unsigned int element, unsigned int index);
std::string name;
unsigned int element;
unsigned int index;
};
struct LinkedVarying
{
LinkedVarying();
LinkedVarying(const std::string &name, GLenum type, GLsizei size, const std::string &semanticName,
unsigned int semanticIndex, unsigned int semanticIndexCount);
// Original GL name
std::string name;
GLenum type;
GLsizei size;
// DirectX semantic information
std::string semanticName;
unsigned int semanticIndex;
unsigned int semanticIndexCount;
};
struct LinkResult
{
bool linkSuccess;
Error error;
LinkResult(bool linkSuccess, const Error &error);
};
// This is the result of linking a program. It is the state that would be passed to ProgramBinary.
class ANGLE_EXPORT ProgramBinary : public RefCountObject
{
public:
explicit ProgramBinary(rx::ProgramImpl *impl);
~ProgramBinary();
rx::ProgramImpl *getImplementation() { return mProgram; }
const rx::ProgramImpl *getImplementation() const { return mProgram; }
GLuint getAttributeLocation(const char *name);
int getSemanticIndex(int attributeIndex);
GLint getSamplerMapping(SamplerType type, unsigned int samplerIndex, const Caps &caps);
GLenum getSamplerTextureType(SamplerType type, unsigned int samplerIndex);
GLint getUsedSamplerRange(SamplerType type);
bool usesPointSize() const;
GLint getUniformLocation(std::string name);
GLuint getUniformIndex(std::string name);
GLuint getUniformBlockIndex(std::string name);
void setUniform1fv(GLint location, GLsizei count, const GLfloat *v);
void setUniform2fv(GLint location, GLsizei count, const GLfloat *v);
void setUniform3fv(GLint location, GLsizei count, const GLfloat *v);
void setUniform4fv(GLint location, GLsizei count, const GLfloat *v);
void setUniform1iv(GLint location, GLsizei count, const GLint *v);
void setUniform2iv(GLint location, GLsizei count, const GLint *v);
void setUniform3iv(GLint location, GLsizei count, const GLint *v);
void setUniform4iv(GLint location, GLsizei count, const GLint *v);
void setUniform1uiv(GLint location, GLsizei count, const GLuint *v);
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 getUniformfv(GLint location, GLfloat *params);
void getUniformiv(GLint location, GLint *params);
void getUniformuiv(GLint location, GLuint *params);
Error applyUniforms();
Error applyUniformBuffers(const std::vector<Buffer*> boundBuffers, const Caps &caps);
LinkResult load(InfoLog &infoLog, GLenum binaryFormat, const void *binary, GLsizei length);
Error save(GLenum *binaryFormat, void *binary, GLsizei bufSize, GLsizei *length);
GLint getLength();
LinkResult link(const Data &data, InfoLog &infoLog, const AttributeBindings &attributeBindings,
Shader *fragmentShader, Shader *vertexShader,
const std::vector<std::string> &transformFeedbackVaryings,
GLenum transformFeedbackBufferMode);
void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
GLint getActiveAttributeCount() const;
GLint getActiveAttributeMaxLength() const;
void getActiveUniform(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
GLint getActiveUniformCount() const;
GLint getActiveUniformMaxLength() const;
GLint getActiveUniformi(GLuint index, GLenum pname) const;
bool isValidUniformLocation(GLint location) const;
LinkedUniform *getUniformByLocation(GLint location) const;
LinkedUniform *getUniformByName(const std::string &name) const;
void getActiveUniformBlockName(GLuint uniformBlockIndex, GLsizei bufSize, GLsizei *length, GLchar *uniformBlockName) const;
void getActiveUniformBlockiv(GLuint uniformBlockIndex, GLenum pname, GLint *params) const;
GLuint getActiveUniformBlockCount() const;
GLuint getActiveUniformBlockMaxLength() const;
UniformBlock *getUniformBlockByIndex(GLuint blockIndex);
GLint getFragDataLocation(const char *name) const;
size_t getTransformFeedbackVaryingCount() const;
const LinkedVarying &getTransformFeedbackVarying(size_t idx) const;
GLenum getTransformFeedbackBufferMode() const;
void validate(InfoLog &infoLog, const Caps &caps);
bool validateSamplers(InfoLog *infoLog, const Caps &caps);
bool isValidated() const;
void updateSamplerMapping();
unsigned int getSerial() const;
void initAttributesByLayout();
void sortAttributesByLayout(rx::TranslatedAttribute attributes[MAX_VERTEX_ATTRIBS], int sortedSemanticIndices[MAX_VERTEX_ATTRIBS]) const;
static bool linkVaryings(InfoLog &infoLog, Shader *fragmentShader, Shader *vertexShader);
static bool linkValidateUniforms(InfoLog &infoLog, const std::string &uniformName, const sh::Uniform &vertexUniform, const sh::Uniform &fragmentUniform);
static bool linkValidateInterfaceBlockFields(InfoLog &infoLog, const std::string &uniformName, const sh::InterfaceBlockField &vertexUniform, const sh::InterfaceBlockField &fragmentUniform);
private:
DISALLOW_COPY_AND_ASSIGN(ProgramBinary);
void reset();
bool linkAttributes(InfoLog &infoLog, const AttributeBindings &attributeBindings, const Shader *vertexShader);
bool linkUniformBlocks(InfoLog &infoLog, const Shader &vertexShader, const Shader &fragmentShader, const Caps &caps);
bool areMatchingInterfaceBlocks(gl::InfoLog &infoLog, const sh::InterfaceBlock &vertexInterfaceBlock,
const sh::InterfaceBlock &fragmentInterfaceBlock);
static bool linkValidateVariablesBase(InfoLog &infoLog,
const std::string &variableName,
const sh::ShaderVariable &vertexVariable,
const sh::ShaderVariable &fragmentVariable,
bool validatePrecision);
static bool linkValidateVaryings(InfoLog &infoLog, const std::string &varyingName, const sh::Varying &vertexVarying, const sh::Varying &fragmentVarying);
bool gatherTransformFeedbackLinkedVaryings(InfoLog &infoLog, const std::vector<LinkedVarying> &linkedVaryings,
const std::vector<std::string> &transformFeedbackVaryingNames,
GLenum transformFeedbackBufferMode,
std::vector<LinkedVarying> *outTransformFeedbackLinkedVaryings,
const Caps &caps) const;
bool assignUniformBlockRegister(InfoLog &infoLog, UniformBlock *uniformBlock, GLenum shader, unsigned int registerIndex, const Caps &caps);
void defineOutputVariables(Shader *fragmentShader);
rx::ProgramImpl *mProgram;
sh::Attribute mLinkedAttribute[MAX_VERTEX_ATTRIBS];
int mSemanticIndex[MAX_VERTEX_ATTRIBS];
int mAttributesByLayout[MAX_VERTEX_ATTRIBS];
std::map<int, VariableLocation> mOutputVariables;
bool mValidated;
const unsigned int mSerial;
static unsigned int issueSerial();
static unsigned int mCurrentSerial;
};
}
#endif // LIBANGLE_PROGRAM_BINARY_H_
...@@ -106,7 +106,7 @@ GLuint ResourceManager::createProgram() ...@@ -106,7 +106,7 @@ GLuint ResourceManager::createProgram()
{ {
GLuint handle = mProgramShaderHandleAllocator.allocate(); GLuint handle = mProgramShaderHandleAllocator.allocate();
mProgramMap[handle] = new Program(mRenderer, this, handle); mProgramMap[handle] = new Program(mRenderer->createProgram(), this, handle);
return handle; return handle;
} }
......
...@@ -138,8 +138,7 @@ void State::initialize(const Caps& caps, GLuint clientVersion) ...@@ -138,8 +138,7 @@ void State::initialize(const Caps& caps, GLuint clientVersion)
mActiveQueries[GL_ANY_SAMPLES_PASSED_CONSERVATIVE].set(NULL); mActiveQueries[GL_ANY_SAMPLES_PASSED_CONSERVATIVE].set(NULL);
mActiveQueries[GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN].set(NULL); mActiveQueries[GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN].set(NULL);
mCurrentProgramId = 0; mProgram = NULL;
mCurrentProgramBinary.set(NULL);
mReadFramebuffer = NULL; mReadFramebuffer = NULL;
mDrawFramebuffer = NULL; mDrawFramebuffer = NULL;
...@@ -163,6 +162,12 @@ void State::reset() ...@@ -163,6 +162,12 @@ void State::reset()
mArrayBuffer.set(NULL); mArrayBuffer.set(NULL);
mRenderbuffer.set(NULL); mRenderbuffer.set(NULL);
if (mProgram)
{
mProgram->release();
}
mProgram = NULL;
mTransformFeedback.set(NULL); mTransformFeedback.set(NULL);
for (State::ActiveQueryMap::iterator i = mActiveQueries.begin(); i != mActiveQueries.end(); i++) for (State::ActiveQueryMap::iterator i = mActiveQueries.begin(); i != mActiveQueries.end(); i++)
...@@ -187,6 +192,8 @@ void State::reset() ...@@ -187,6 +192,8 @@ void State::reset()
mPack.pixelBuffer.set(NULL); mPack.pixelBuffer.set(NULL);
mUnpack.pixelBuffer.set(NULL); mUnpack.pixelBuffer.set(NULL);
mProgram = NULL;
} }
const RasterizerState &State::getRasterizerState() const const RasterizerState &State::getRasterizerState() const
...@@ -845,31 +852,27 @@ bool State::removeVertexArrayBinding(GLuint vertexArray) ...@@ -845,31 +852,27 @@ bool State::removeVertexArrayBinding(GLuint vertexArray)
return false; return false;
} }
void State::setCurrentProgram(GLuint programId, Program *newProgram) void State::setProgram(Program *newProgram)
{ {
mCurrentProgramId = programId; // set new ID before trying to delete program binary; otherwise it will only be flagged for deletion if (mProgram != newProgram)
mCurrentProgramBinary.set(NULL);
if (newProgram)
{ {
newProgram->addRef(); if (mProgram)
mCurrentProgramBinary.set(newProgram->getProgramBinary()); {
} mProgram->release();
} }
void State::setCurrentProgramBinary(ProgramBinary *binary) mProgram = newProgram;
{
mCurrentProgramBinary.set(binary);
}
GLuint State::getCurrentProgramId() const if (mProgram)
{ {
return mCurrentProgramId; newProgram->addRef();
}
}
} }
ProgramBinary *State::getCurrentProgramBinary() const Program *State::getProgram() const
{ {
return mCurrentProgramBinary.get(); return mProgram;
} }
void State::setTransformFeedbackBinding(TransformFeedback *transformFeedback) void State::setTransformFeedbackBinding(TransformFeedback *transformFeedback)
...@@ -1214,7 +1217,7 @@ void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params) ...@@ -1214,7 +1217,7 @@ void State::getIntegerv(const gl::Data &data, GLenum pname, GLint *params)
case GL_READ_FRAMEBUFFER_BINDING_ANGLE: *params = mReadFramebuffer->id(); break; case GL_READ_FRAMEBUFFER_BINDING_ANGLE: *params = mReadFramebuffer->id(); break;
case GL_RENDERBUFFER_BINDING: *params = mRenderbuffer.id(); break; case GL_RENDERBUFFER_BINDING: *params = mRenderbuffer.id(); break;
case GL_VERTEX_ARRAY_BINDING: *params = mVertexArray->id(); break; case GL_VERTEX_ARRAY_BINDING: *params = mVertexArray->id(); break;
case GL_CURRENT_PROGRAM: *params = mCurrentProgramId; break; case GL_CURRENT_PROGRAM: *params = mProgram ? mProgram->id() : 0; break;
case GL_PACK_ALIGNMENT: *params = mPack.alignment; break; case GL_PACK_ALIGNMENT: *params = mPack.alignment; break;
case GL_PACK_REVERSE_ROW_ORDER_ANGLE: *params = mPack.reverseRowOrder; break; case GL_PACK_REVERSE_ROW_ORDER_ANGLE: *params = mPack.reverseRowOrder; break;
case GL_UNPACK_ALIGNMENT: *params = mUnpack.alignment; break; case GL_UNPACK_ALIGNMENT: *params = mUnpack.alignment; break;
......
...@@ -168,10 +168,8 @@ class ANGLE_EXPORT State ...@@ -168,10 +168,8 @@ class ANGLE_EXPORT State
bool removeVertexArrayBinding(GLuint vertexArray); bool removeVertexArrayBinding(GLuint vertexArray);
// Program binding manipulation // Program binding manipulation
void setCurrentProgram(GLuint programId, Program *newProgram); void setProgram(Program *newProgram);
void setCurrentProgramBinary(ProgramBinary *binary); Program *getProgram() const;
GLuint getCurrentProgramId() const;
ProgramBinary *getCurrentProgramBinary() const;
// Transform feedback object (not buffer) binding manipulation // Transform feedback object (not buffer) binding manipulation
void setTransformFeedbackBinding(TransformFeedback *transformFeedback); void setTransformFeedbackBinding(TransformFeedback *transformFeedback);
...@@ -285,8 +283,7 @@ class ANGLE_EXPORT State ...@@ -285,8 +283,7 @@ class ANGLE_EXPORT State
Framebuffer *mReadFramebuffer; Framebuffer *mReadFramebuffer;
Framebuffer *mDrawFramebuffer; Framebuffer *mDrawFramebuffer;
BindingPointer<Renderbuffer> mRenderbuffer; BindingPointer<Renderbuffer> mRenderbuffer;
GLuint mCurrentProgramId; Program *mProgram;
BindingPointer<ProgramBinary> mCurrentProgramBinary;
typedef std::vector<VertexAttribCurrentValueData> VertexAttribVector; typedef std::vector<VertexAttribCurrentValueData> VertexAttribVector;
VertexAttribVector mVertexAttribCurrentValues; // From glVertexAttrib VertexAttribVector mVertexAttribCurrentValues; // From glVertexAttrib
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// angletypes.h : Defines a variety of structures and enum types that are used throughout libGLESv2 // angletypes.h : Defines a variety of structures and enum types that are used throughout libGLESv2
#include "libANGLE/angletypes.h" #include "libANGLE/angletypes.h"
#include "libANGLE/ProgramBinary.h" #include "libANGLE/Program.h"
#include "libANGLE/VertexAttribute.h" #include "libANGLE/VertexAttribute.h"
#include "libANGLE/State.h" #include "libANGLE/State.h"
#include "libANGLE/VertexArray.h" #include "libANGLE/VertexArray.h"
...@@ -149,13 +149,13 @@ VertexFormat::VertexFormat(const VertexAttribute &attrib, GLenum currentValueTyp ...@@ -149,13 +149,13 @@ VertexFormat::VertexFormat(const VertexAttribute &attrib, GLenum currentValueTyp
} }
void VertexFormat::GetInputLayout(VertexFormat *inputLayout, void VertexFormat::GetInputLayout(VertexFormat *inputLayout,
ProgramBinary *programBinary, Program *program,
const State &state) const State &state)
{ {
const VertexAttribute *vertexAttributes = state.getVertexArray()->getVertexAttributes(); const VertexAttribute *vertexAttributes = state.getVertexArray()->getVertexAttributes();
for (unsigned int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++) for (unsigned int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{ {
int semanticIndex = programBinary->getSemanticIndex(attributeIndex); int semanticIndex = program->getSemanticIndex(attributeIndex);
if (semanticIndex != -1) if (semanticIndex != -1)
{ {
......
...@@ -18,7 +18,7 @@ namespace gl ...@@ -18,7 +18,7 @@ namespace gl
{ {
class Buffer; class Buffer;
class State; class State;
class ProgramBinary; class Program;
struct VertexAttribute; struct VertexAttribute;
struct VertexAttribCurrentValueData; struct VertexAttribCurrentValueData;
...@@ -233,7 +233,7 @@ struct VertexFormat ...@@ -233,7 +233,7 @@ struct VertexFormat
VertexFormat(const VertexAttribute &attribute, GLenum currentValueType); VertexFormat(const VertexAttribute &attribute, GLenum currentValueType);
static void GetInputLayout(VertexFormat *inputLayout, static void GetInputLayout(VertexFormat *inputLayout,
ProgramBinary *programBinary, Program *program,
const State& currentValues); const State& currentValues);
bool operator==(const VertexFormat &other) const; bool operator==(const VertexFormat &other) const;
......
...@@ -34,6 +34,12 @@ unsigned int ParseAndStripArrayIndex(std::string* name) ...@@ -34,6 +34,12 @@ unsigned int ParseAndStripArrayIndex(std::string* name)
} }
LinkResult::LinkResult(bool linkSuccess, const gl::Error &error)
: linkSuccess(linkSuccess),
error(error)
{
}
ProgramImpl::~ProgramImpl() ProgramImpl::~ProgramImpl()
{ {
// Ensure that reset was called by the inherited class during destruction // Ensure that reset was called by the inherited class during destruction
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libANGLE/BinaryStream.h" #include "libANGLE/BinaryStream.h"
#include "libANGLE/Constants.h" #include "libANGLE/Constants.h"
#include "libANGLE/ProgramBinary.h" #include "libANGLE/Program.h"
#include "libANGLE/Shader.h" #include "libANGLE/Shader.h"
#include "libANGLE/renderer/Renderer.h" #include "libANGLE/renderer/Renderer.h"
...@@ -21,6 +21,13 @@ ...@@ -21,6 +21,13 @@
namespace rx namespace rx
{ {
struct LinkResult
{
bool linkSuccess;
gl::Error error;
LinkResult(bool linkSuccess, const gl::Error &error);
};
class ProgramImpl class ProgramImpl
{ {
public: public:
...@@ -52,15 +59,15 @@ class ProgramImpl ...@@ -52,15 +59,15 @@ class ProgramImpl
virtual GLenum getTransformFeedbackBufferMode() const = 0; virtual GLenum getTransformFeedbackBufferMode() const = 0;
virtual GLenum getBinaryFormat() = 0; virtual GLenum getBinaryFormat() = 0;
virtual gl::LinkResult load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) = 0; virtual LinkResult load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream) = 0;
virtual gl::Error save(gl::BinaryOutputStream *stream) = 0; virtual gl::Error save(gl::BinaryOutputStream *stream) = 0;
virtual gl::LinkResult link(const gl::Data &data, gl::InfoLog &infoLog, virtual LinkResult link(const gl::Data &data, gl::InfoLog &infoLog,
gl::Shader *fragmentShader, gl::Shader *vertexShader, gl::Shader *fragmentShader, gl::Shader *vertexShader,
const std::vector<std::string> &transformFeedbackVaryings, const std::vector<std::string> &transformFeedbackVaryings,
GLenum transformFeedbackBufferMode, GLenum transformFeedbackBufferMode,
int *registers, std::vector<gl::LinkedVarying> *linkedVaryings, int *registers, std::vector<gl::LinkedVarying> *linkedVaryings,
std::map<int, gl::VariableLocation> *outputVariables) = 0; std::map<int, gl::VariableLocation> *outputVariables) = 0;
virtual void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) = 0; virtual void setUniform1fv(GLint location, GLsizei count, const GLfloat *v) = 0;
virtual void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) = 0; virtual void setUniform2fv(GLint location, GLsizei count, const GLfloat *v) = 0;
...@@ -98,8 +105,8 @@ class ProgramImpl ...@@ -98,8 +105,8 @@ class ProgramImpl
virtual void updateSamplerMapping() = 0; virtual void updateSamplerMapping() = 0;
virtual bool validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) = 0; virtual bool validateSamplers(gl::InfoLog *infoLog, const gl::Caps &caps) = 0;
virtual gl::LinkResult compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader, virtual LinkResult compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
int registers) = 0; int registers) = 0;
virtual bool linkUniforms(gl::InfoLog &infoLog, const gl::Shader &vertexShader, const gl::Shader &fragmentShader, virtual bool linkUniforms(gl::InfoLog &infoLog, const gl::Shader &vertexShader, const gl::Shader &fragmentShader,
const gl::Caps &caps) = 0; const gl::Caps &caps) = 0;
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "libANGLE/renderer/d3d/ShaderD3D.h" #include "libANGLE/renderer/d3d/ShaderD3D.h"
#include "libANGLE/renderer/d3d/RendererD3D.h" #include "libANGLE/renderer/d3d/RendererD3D.h"
#include "libANGLE/Program.h" #include "libANGLE/Program.h"
#include "libANGLE/ProgramBinary.h"
#include "libANGLE/Shader.h" #include "libANGLE/Shader.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "libANGLE/renderer/ProgramImpl.h" #include "libANGLE/renderer/ProgramImpl.h"
#include "libANGLE/renderer/Workarounds.h" #include "libANGLE/renderer/Workarounds.h"
#include "libANGLE/renderer/d3d/DynamicHLSL.h"
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -26,6 +27,7 @@ namespace rx ...@@ -26,6 +27,7 @@ namespace rx
{ {
class RendererD3D; class RendererD3D;
class UniformStorage; class UniformStorage;
class ShaderExecutable;
class ProgramD3D : public ProgramImpl class ProgramD3D : public ProgramImpl
{ {
...@@ -51,7 +53,7 @@ class ProgramD3D : public ProgramImpl ...@@ -51,7 +53,7 @@ class ProgramD3D : public ProgramImpl
bool usesGeometryShader() const; bool usesGeometryShader() const;
GLenum getBinaryFormat() { return GL_PROGRAM_BINARY_ANGLE; } GLenum getBinaryFormat() { return GL_PROGRAM_BINARY_ANGLE; }
gl::LinkResult load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream); LinkResult load(gl::InfoLog &infoLog, gl::BinaryInputStream *stream);
gl::Error save(gl::BinaryOutputStream *stream); gl::Error save(gl::BinaryOutputStream *stream);
gl::Error getPixelExecutableForFramebuffer(const gl::Framebuffer *fbo, ShaderExecutable **outExectuable); gl::Error getPixelExecutableForFramebuffer(const gl::Framebuffer *fbo, ShaderExecutable **outExectuable);
...@@ -59,15 +61,15 @@ class ProgramD3D : public ProgramImpl ...@@ -59,15 +61,15 @@ class ProgramD3D : public ProgramImpl
gl::Error getVertexExecutableForInputLayout(const gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS], ShaderExecutable **outExectuable); gl::Error getVertexExecutableForInputLayout(const gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS], ShaderExecutable **outExectuable);
ShaderExecutable *getGeometryExecutable() const { return mGeometryExecutable; } ShaderExecutable *getGeometryExecutable() const { return mGeometryExecutable; }
gl::LinkResult compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader, LinkResult compileProgramExecutables(gl::InfoLog &infoLog, gl::Shader *fragmentShader, gl::Shader *vertexShader,
int registers); int registers);
gl::LinkResult link(const gl::Data &data, gl::InfoLog &infoLog, LinkResult link(const gl::Data &data, gl::InfoLog &infoLog,
gl::Shader *fragmentShader, gl::Shader *vertexShader, gl::Shader *fragmentShader, gl::Shader *vertexShader,
const std::vector<std::string> &transformFeedbackVaryings, const std::vector<std::string> &transformFeedbackVaryings,
GLenum transformFeedbackBufferMode, GLenum transformFeedbackBufferMode,
int *registers, std::vector<gl::LinkedVarying> *linkedVaryings, int *registers, std::vector<gl::LinkedVarying> *linkedVaryings,
std::map<int, gl::VariableLocation> *outputVariables); std::map<int, gl::VariableLocation> *outputVariables);
void getInputLayoutSignature(const gl::VertexFormat inputLayout[], GLenum signature[]) const; void getInputLayoutSignature(const gl::VertexFormat inputLayout[], GLenum signature[]) const;
...@@ -113,6 +115,8 @@ class ProgramD3D : public ProgramImpl ...@@ -113,6 +115,8 @@ class ProgramD3D : public ProgramImpl
void reset(); void reset();
unsigned int getSerial() const;
private: private:
DISALLOW_COPY_AND_ASSIGN(ProgramD3D); DISALLOW_COPY_AND_ASSIGN(ProgramD3D);
...@@ -212,6 +216,11 @@ class ProgramD3D : public ProgramImpl ...@@ -212,6 +216,11 @@ class ProgramD3D : public ProgramImpl
bool mDirtySamplerMapping; bool mDirtySamplerMapping;
int mShaderVersion; int mShaderVersion;
unsigned int mSerial;
static unsigned int issueSerial();
static unsigned int mCurrentSerial;
}; };
} }
......
...@@ -53,10 +53,10 @@ gl::Error RendererD3D::drawElements(const gl::Data &data, ...@@ -53,10 +53,10 @@ gl::Error RendererD3D::drawElements(const gl::Data &data,
const GLvoid *indices, GLsizei instances, const GLvoid *indices, GLsizei instances,
const RangeUI &indexRange) const RangeUI &indexRange)
{ {
ASSERT(data.state->getCurrentProgramId() != 0); gl::Program *program = data.state->getProgram();
ASSERT(program != NULL);
gl::ProgramBinary *programBinary = data.state->getCurrentProgramBinary(); program->updateSamplerMapping();
programBinary->updateSamplerMapping();
gl::Error error = generateSwizzles(data); gl::Error error = generateSwizzles(data);
if (error.isError()) if (error.isError())
...@@ -136,10 +136,10 @@ gl::Error RendererD3D::drawArrays(const gl::Data &data, ...@@ -136,10 +136,10 @@ gl::Error RendererD3D::drawArrays(const gl::Data &data,
GLenum mode, GLint first, GLenum mode, GLint first,
GLsizei count, GLsizei instances) GLsizei count, GLsizei instances)
{ {
ASSERT(data.state->getCurrentProgramId() != 0); gl::Program *program = data.state->getProgram();
ASSERT(program != NULL);
gl::ProgramBinary *programBinary = data.state->getCurrentProgramBinary(); program->updateSamplerMapping();
programBinary->updateSamplerMapping();
gl::Error error = generateSwizzles(data); gl::Error error = generateSwizzles(data);
if (error.isError()) if (error.isError())
...@@ -209,14 +209,14 @@ gl::Error RendererD3D::drawArrays(const gl::Data &data, ...@@ -209,14 +209,14 @@ gl::Error RendererD3D::drawArrays(const gl::Data &data,
gl::Error RendererD3D::generateSwizzles(const gl::Data &data, gl::SamplerType type) gl::Error RendererD3D::generateSwizzles(const gl::Data &data, gl::SamplerType type)
{ {
gl::ProgramBinary *programBinary = data.state->getCurrentProgramBinary(); gl::Program *program = data.state->getProgram();
size_t samplerRange = programBinary->getUsedSamplerRange(type); size_t samplerRange = program->getUsedSamplerRange(type);
for (size_t i = 0; i < samplerRange; i++) for (size_t i = 0; i < samplerRange; i++)
{ {
GLenum textureType = programBinary->getSamplerTextureType(type, i); GLenum textureType = program->getSamplerTextureType(type, i);
GLint textureUnit = programBinary->getSamplerMapping(type, i, *data.caps); GLint textureUnit = program->getSamplerMapping(type, i, *data.caps);
if (textureUnit != -1) if (textureUnit != -1)
{ {
gl::Texture *texture = data.state->getSamplerTexture(textureUnit, textureType); gl::Texture *texture = data.state->getSamplerTexture(textureUnit, textureType);
...@@ -355,20 +355,20 @@ bool RendererD3D::applyTransformFeedbackBuffers(const gl::Data &data) ...@@ -355,20 +355,20 @@ bool RendererD3D::applyTransformFeedbackBuffers(const gl::Data &data)
// Applies the shaders and shader constants to the Direct3D device // Applies the shaders and shader constants to the Direct3D device
gl::Error RendererD3D::applyShaders(const gl::Data &data, bool transformFeedbackActive) gl::Error RendererD3D::applyShaders(const gl::Data &data, bool transformFeedbackActive)
{ {
gl::ProgramBinary *programBinary = data.state->getCurrentProgramBinary(); gl::Program *program = data.state->getProgram();
gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS]; gl::VertexFormat inputLayout[gl::MAX_VERTEX_ATTRIBS];
gl::VertexFormat::GetInputLayout(inputLayout, programBinary, *data.state); gl::VertexFormat::GetInputLayout(inputLayout, program, *data.state);
const gl::Framebuffer *fbo = data.state->getDrawFramebuffer(); const gl::Framebuffer *fbo = data.state->getDrawFramebuffer();
gl::Error error = applyShaders(programBinary, inputLayout, fbo, data.state->getRasterizerState().rasterizerDiscard, transformFeedbackActive); gl::Error error = applyShaders(program, inputLayout, fbo, data.state->getRasterizerState().rasterizerDiscard, transformFeedbackActive);
if (error.isError()) if (error.isError())
{ {
return error; return error;
} }
return programBinary->applyUniforms(); return program->applyUniforms();
} }
// For each Direct3D sampler of either the pixel or vertex stage, // For each Direct3D sampler of either the pixel or vertex stage,
...@@ -377,13 +377,13 @@ gl::Error RendererD3D::applyShaders(const gl::Data &data, bool transformFeedback ...@@ -377,13 +377,13 @@ gl::Error RendererD3D::applyShaders(const gl::Data &data, bool transformFeedback
gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shaderType, gl::Error RendererD3D::applyTextures(const gl::Data &data, gl::SamplerType shaderType,
const FramebufferTextureSerialArray &framebufferSerials, size_t framebufferSerialCount) const FramebufferTextureSerialArray &framebufferSerials, size_t framebufferSerialCount)
{ {
gl::ProgramBinary *programBinary = data.state->getCurrentProgramBinary(); gl::Program *program = data.state->getProgram();
size_t samplerRange = programBinary->getUsedSamplerRange(shaderType); size_t samplerRange = program->getUsedSamplerRange(shaderType);
for (size_t samplerIndex = 0; samplerIndex < samplerRange; samplerIndex++) for (size_t samplerIndex = 0; samplerIndex < samplerRange; samplerIndex++)
{ {
GLenum textureType = programBinary->getSamplerTextureType(shaderType, samplerIndex); GLenum textureType = program->getSamplerTextureType(shaderType, samplerIndex);
GLint textureUnit = programBinary->getSamplerMapping(shaderType, samplerIndex, *data.caps); GLint textureUnit = program->getSamplerMapping(shaderType, samplerIndex, *data.caps);
if (textureUnit != -1) if (textureUnit != -1)
{ {
gl::Texture *texture = data.state->getSamplerTexture(textureUnit, textureType); gl::Texture *texture = data.state->getSamplerTexture(textureUnit, textureType);
...@@ -471,14 +471,13 @@ gl::Error RendererD3D::applyTextures(const gl::Data &data) ...@@ -471,14 +471,13 @@ gl::Error RendererD3D::applyTextures(const gl::Data &data)
gl::Error RendererD3D::applyUniformBuffers(const gl::Data &data) gl::Error RendererD3D::applyUniformBuffers(const gl::Data &data)
{ {
gl::Program *programObject = data.resourceManager->getProgram(data.state->getCurrentProgramId()); gl::Program *program = data.state->getProgram();
gl::ProgramBinary *programBinary = programObject->getProgramBinary();
std::vector<gl::Buffer*> boundBuffers; std::vector<gl::Buffer*> boundBuffers;
for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < programBinary->getActiveUniformBlockCount(); uniformBlockIndex++) for (unsigned int uniformBlockIndex = 0; uniformBlockIndex < program->getActiveUniformBlockCount(); uniformBlockIndex++)
{ {
GLuint blockBinding = programObject->getUniformBlockBinding(uniformBlockIndex); GLuint blockBinding = program->getUniformBlockBinding(uniformBlockIndex);
if (data.state->getIndexedUniformBuffer(blockBinding)->id() == 0) if (data.state->getIndexedUniformBuffer(blockBinding)->id() == 0)
{ {
...@@ -493,7 +492,7 @@ gl::Error RendererD3D::applyUniformBuffers(const gl::Data &data) ...@@ -493,7 +492,7 @@ gl::Error RendererD3D::applyUniformBuffers(const gl::Data &data)
} }
} }
return programBinary->applyUniformBuffers(boundBuffers, *data.caps); return program->applyUniformBuffers(boundBuffers, *data.caps);
} }
bool RendererD3D::skipDraw(const gl::Data &data, GLenum drawMode) bool RendererD3D::skipDraw(const gl::Data &data, GLenum drawMode)
...@@ -503,7 +502,7 @@ bool RendererD3D::skipDraw(const gl::Data &data, GLenum drawMode) ...@@ -503,7 +502,7 @@ bool RendererD3D::skipDraw(const gl::Data &data, GLenum drawMode)
// ProgramBinary assumes non-point rendering if gl_PointSize isn't written, // ProgramBinary assumes non-point rendering if gl_PointSize isn't written,
// which affects varying interpolation. Since the value of gl_PointSize is // which affects varying interpolation. Since the value of gl_PointSize is
// undefined when not written, just skip drawing to avoid unexpected results. // undefined when not written, just skip drawing to avoid unexpected results.
if (!data.state->getCurrentProgramBinary()->usesPointSize()) if (!data.state->getProgram()->usesPointSize())
{ {
// This is stictly speaking not an error, but developers should be // This is stictly speaking not an error, but developers should be
// notified of risking undefined behavior. // notified of risking undefined behavior.
......
...@@ -91,7 +91,7 @@ class RendererD3D : public Renderer ...@@ -91,7 +91,7 @@ class RendererD3D : public Renderer
bool ignoreViewport) = 0; bool ignoreViewport) = 0;
virtual gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) = 0; virtual gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) = 0;
virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, virtual gl::Error applyShaders(gl::Program *program, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive) = 0; bool rasterizerDiscard, bool transformFeedbackActive) = 0;
virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray) = 0; virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray) = 0;
virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount) = 0; virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount) = 0;
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
#include "libANGLE/renderer/d3d/VertexBuffer.h" #include "libANGLE/renderer/d3d/VertexBuffer.h"
#include "libANGLE/renderer/Renderer.h" #include "libANGLE/renderer/Renderer.h"
#include "libANGLE/Buffer.h" #include "libANGLE/Buffer.h"
#include "libANGLE/ProgramBinary.h" #include "libANGLE/Program.h"
#include "libANGLE/VertexAttribute.h" #include "libANGLE/VertexAttribute.h"
#include "libANGLE/State.h" #include "libANGLE/State.h"
...@@ -94,7 +94,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta ...@@ -94,7 +94,7 @@ gl::Error VertexDataManager::prepareVertexData(const gl::State &state, GLint sta
// Invalidate static buffers that don't contain matching attributes // Invalidate static buffers that don't contain matching attributes
for (int attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++) for (int attributeIndex = 0; attributeIndex < gl::MAX_VERTEX_ATTRIBS; attributeIndex++)
{ {
translated[attributeIndex].active = (state.getCurrentProgramBinary()->getSemanticIndex(attributeIndex) != -1); translated[attributeIndex].active = (state.getProgram()->getSemanticIndex(attributeIndex) != -1);
const gl::VertexAttribute &curAttrib = state.getVertexAttribState(attributeIndex); const gl::VertexAttribute &curAttrib = state.getVertexAttribState(attributeIndex);
if (translated[attributeIndex].active && curAttrib.enabled) if (translated[attributeIndex].active && curAttrib.enabled)
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
namespace gl namespace gl
{ {
class ProgramBinary;
class State; class State;
struct VertexAttribute; struct VertexAttribute;
struct VertexAttribCurrentValueData; struct VertexAttribCurrentValueData;
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/ProgramD3D.h" #include "libANGLE/renderer/d3d/ProgramD3D.h"
#include "libANGLE/renderer/d3d/VertexDataManager.h" #include "libANGLE/renderer/d3d/VertexDataManager.h"
#include "libANGLE/ProgramBinary.h" #include "libANGLE/Program.h"
#include "libANGLE/VertexAttribute.h" #include "libANGLE/VertexAttribute.h"
#include "third_party/murmurhash/MurmurHash3.h" #include "third_party/murmurhash/MurmurHash3.h"
...@@ -87,10 +87,10 @@ void InputLayoutCache::markDirty() ...@@ -87,10 +87,10 @@ void InputLayoutCache::markDirty()
} }
gl::Error InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS], gl::Error InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS],
gl::ProgramBinary *programBinary) gl::Program *program)
{ {
int sortedSemanticIndices[gl::MAX_VERTEX_ATTRIBS]; int sortedSemanticIndices[gl::MAX_VERTEX_ATTRIBS];
programBinary->sortAttributesByLayout(attributes, sortedSemanticIndices); program->sortAttributesByLayout(attributes, sortedSemanticIndices);
if (!mDevice || !mDeviceContext) if (!mDevice || !mDeviceContext)
{ {
...@@ -113,7 +113,7 @@ gl::Error InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl ...@@ -113,7 +113,7 @@ gl::Error InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl
// Record the type of the associated vertex shader vector in our key // Record the type of the associated vertex shader vector in our key
// This will prevent mismatched vertex shaders from using the same input layout // This will prevent mismatched vertex shaders from using the same input layout
GLint attributeSize; GLint attributeSize;
programBinary->getActiveAttribute(ilKey.elementCount, 0, NULL, &attributeSize, &ilKey.elements[ilKey.elementCount].glslElementType, NULL); program->getActiveAttribute(ilKey.elementCount, 0, NULL, &attributeSize, &ilKey.elements[ilKey.elementCount].glslElementType, NULL);
ilKey.elements[ilKey.elementCount].desc.SemanticName = semanticName; ilKey.elements[ilKey.elementCount].desc.SemanticName = semanticName;
ilKey.elements[ilKey.elementCount].desc.SemanticIndex = sortedSemanticIndices[i]; ilKey.elements[ilKey.elementCount].desc.SemanticIndex = sortedSemanticIndices[i];
...@@ -138,7 +138,7 @@ gl::Error InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl ...@@ -138,7 +138,7 @@ gl::Error InputLayoutCache::applyVertexBuffers(TranslatedAttribute attributes[gl
{ {
gl::VertexFormat shaderInputLayout[gl::MAX_VERTEX_ATTRIBS]; gl::VertexFormat shaderInputLayout[gl::MAX_VERTEX_ATTRIBS];
GetInputLayout(attributes, shaderInputLayout); GetInputLayout(attributes, shaderInputLayout);
ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(programBinary->getImplementation()); ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(program->getImplementation());
ShaderExecutable *shader = NULL; ShaderExecutable *shader = NULL;
gl::Error error = programD3D->getVertexExecutableForInputLayout(shaderInputLayout, &shader); gl::Error error = programD3D->getVertexExecutableForInputLayout(shaderInputLayout, &shader);
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
namespace gl namespace gl
{ {
class ProgramBinary; class Program;
} }
namespace rx namespace rx
...@@ -39,7 +39,7 @@ class InputLayoutCache ...@@ -39,7 +39,7 @@ class InputLayoutCache
void markDirty(); void markDirty();
gl::Error applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS], gl::Error applyVertexBuffers(TranslatedAttribute attributes[gl::MAX_VERTEX_ATTRIBS],
gl::ProgramBinary *programBinary); gl::Program *program);
private: private:
DISALLOW_COPY_AND_ASSIGN(InputLayoutCache); DISALLOW_COPY_AND_ASSIGN(InputLayoutCache);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "libANGLE/Display.h" #include "libANGLE/Display.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/ProgramBinary.h" #include "libANGLE/Program.h"
#include "libANGLE/State.h" #include "libANGLE/State.h"
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
#include "libANGLE/renderer/d3d/FramebufferD3D.h" #include "libANGLE/renderer/d3d/FramebufferD3D.h"
...@@ -1073,7 +1073,7 @@ gl::Error Renderer11::applyVertexBuffer(const gl::State &state, GLint first, GLs ...@@ -1073,7 +1073,7 @@ gl::Error Renderer11::applyVertexBuffer(const gl::State &state, GLint first, GLs
return error; return error;
} }
return mInputLayoutCache.applyVertexBuffers(attributes, state.getCurrentProgramBinary()); return mInputLayoutCache.applyVertexBuffers(attributes, state.getProgram());
} }
gl::Error Renderer11::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) gl::Error Renderer11::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo)
...@@ -1478,10 +1478,10 @@ gl::Error Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid * ...@@ -1478,10 +1478,10 @@ gl::Error Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer11::applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, gl::Error Renderer11::applyShaders(gl::Program *program, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive) bool rasterizerDiscard, bool transformFeedbackActive)
{ {
ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(programBinary->getImplementation()); ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(program->getImplementation());
ShaderExecutable *vertexExe = NULL; ShaderExecutable *vertexExe = NULL;
gl::Error error = programD3D->getVertexExecutableForInputLayout(inputLayout, &vertexExe); gl::Error error = programD3D->getVertexExecutableForInputLayout(inputLayout, &vertexExe);
......
...@@ -82,7 +82,7 @@ class Renderer11 : public RendererD3D ...@@ -82,7 +82,7 @@ class Renderer11 : public RendererD3D
virtual bool applyPrimitiveType(GLenum mode, GLsizei count); virtual bool applyPrimitiveType(GLenum mode, GLsizei count);
gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) override; gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) override;
virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, virtual gl::Error applyShaders(gl::Program *program, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive); bool rasterizerDiscard, bool transformFeedbackActive);
virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray); virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray);
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "libANGLE/renderer/d3d/d3d11/formatutils11.h" #include "libANGLE/renderer/d3d/d3d11/formatutils11.h"
#include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h" #include "libANGLE/renderer/d3d/d3d11/RenderTarget11.h"
#include "libANGLE/renderer/Workarounds.h" #include "libANGLE/renderer/Workarounds.h"
#include "libANGLE/ProgramBinary.h" #include "libANGLE/Program.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "common/debug.h" #include "common/debug.h"
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "libANGLE/Display.h" #include "libANGLE/Display.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/ProgramBinary.h" #include "libANGLE/Program.h"
#include "libANGLE/Renderbuffer.h" #include "libANGLE/Renderbuffer.h"
#include "libANGLE/State.h" #include "libANGLE/State.h"
#include "libANGLE/Surface.h" #include "libANGLE/Surface.h"
...@@ -1320,7 +1320,7 @@ gl::Error Renderer9::applyVertexBuffer(const gl::State &state, GLint first, GLsi ...@@ -1320,7 +1320,7 @@ gl::Error Renderer9::applyVertexBuffer(const gl::State &state, GLint first, GLsi
return error; return error;
} }
return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, state.getCurrentProgramBinary(), instances, &mRepeatDraw); return mVertexDeclarationCache.applyDeclaration(mDevice, attributes, state.getProgram(), instances, &mRepeatDraw);
} }
// Applies the indices and element array bindings to the Direct3D 9 device // Applies the indices and element array bindings to the Direct3D 9 device
...@@ -1719,13 +1719,13 @@ gl::Error Renderer9::getCountingIB(size_t count, StaticIndexBufferInterface **ou ...@@ -1719,13 +1719,13 @@ gl::Error Renderer9::getCountingIB(size_t count, StaticIndexBufferInterface **ou
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
gl::Error Renderer9::applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, gl::Error Renderer9::applyShaders(gl::Program *program, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive) bool rasterizerDiscard, bool transformFeedbackActive)
{ {
ASSERT(!transformFeedbackActive); ASSERT(!transformFeedbackActive);
ASSERT(!rasterizerDiscard); ASSERT(!rasterizerDiscard);
ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(programBinary->getImplementation()); ProgramD3D *programD3D = ProgramD3D::makeProgramD3D(program->getImplementation());
ShaderExecutable *vertexExe = NULL; ShaderExecutable *vertexExe = NULL;
gl::Error error = programD3D->getVertexExecutableForInputLayout(inputLayout, &vertexExe); gl::Error error = programD3D->getVertexExecutableForInputLayout(inputLayout, &vertexExe);
...@@ -1761,7 +1761,7 @@ gl::Error Renderer9::applyShaders(gl::ProgramBinary *programBinary, const gl::Ve ...@@ -1761,7 +1761,7 @@ gl::Error Renderer9::applyShaders(gl::ProgramBinary *programBinary, const gl::Ve
// per-program, checking the program serial guarantees we upload fresh // per-program, checking the program serial guarantees we upload fresh
// uniform data even if our shader pointers are the same. // uniform data even if our shader pointers are the same.
// https://code.google.com/p/angleproject/issues/detail?id=661 // https://code.google.com/p/angleproject/issues/detail?id=661
unsigned int programSerial = programBinary->getSerial(); unsigned int programSerial = programD3D->getSerial();
if (programSerial != mAppliedProgramSerial) if (programSerial != mAppliedProgramSerial)
{ {
programD3D->dirtyAllUniforms(); programD3D->dirtyAllUniforms();
......
...@@ -82,7 +82,7 @@ class Renderer9 : public RendererD3D ...@@ -82,7 +82,7 @@ class Renderer9 : public RendererD3D
bool ignoreViewport); bool ignoreViewport);
gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) override; gl::Error applyRenderTarget(const gl::Framebuffer *frameBuffer) override;
virtual gl::Error applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer, virtual gl::Error applyShaders(gl::Program *program, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
bool rasterizerDiscard, bool transformFeedbackActive); bool rasterizerDiscard, bool transformFeedbackActive);
virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray); virtual gl::Error applyUniforms(const ProgramImpl &program, const std::vector<gl::LinkedUniform*> &uniformArray);
virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount); virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include "libANGLE/renderer/d3d/d3d9/VertexDeclarationCache.h" #include "libANGLE/renderer/d3d/d3d9/VertexDeclarationCache.h"
#include "libANGLE/renderer/d3d/d3d9/VertexBuffer9.h" #include "libANGLE/renderer/d3d/d3d9/VertexBuffer9.h"
#include "libANGLE/renderer/d3d/d3d9/formatutils9.h" #include "libANGLE/renderer/d3d/d3d9/formatutils9.h"
#include "libANGLE/ProgramBinary.h" #include "libANGLE/Program.h"
#include "libANGLE/VertexAttribute.h" #include "libANGLE/VertexAttribute.h"
namespace rx namespace rx
...@@ -40,7 +40,7 @@ VertexDeclarationCache::~VertexDeclarationCache() ...@@ -40,7 +40,7 @@ VertexDeclarationCache::~VertexDeclarationCache()
} }
} }
gl::Error VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], gl::ProgramBinary *programBinary, GLsizei instances, GLsizei *repeatDraw) gl::Error VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], gl::Program *program, GLsizei instances, GLsizei *repeatDraw)
{ {
*repeatDraw = 1; *repeatDraw = 1;
...@@ -155,7 +155,7 @@ gl::Error VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, Tra ...@@ -155,7 +155,7 @@ gl::Error VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, Tra
element->Type = d3d9VertexInfo.nativeFormat; element->Type = d3d9VertexInfo.nativeFormat;
element->Method = D3DDECLMETHOD_DEFAULT; element->Method = D3DDECLMETHOD_DEFAULT;
element->Usage = D3DDECLUSAGE_TEXCOORD; element->Usage = D3DDECLUSAGE_TEXCOORD;
element->UsageIndex = programBinary->getSemanticIndex(i); element->UsageIndex = program->getSemanticIndex(i);
element++; element++;
} }
} }
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
namespace gl namespace gl
{ {
class VertexDataManager; class VertexDataManager;
class Program;
} }
namespace rx namespace rx
...@@ -26,7 +27,7 @@ class VertexDeclarationCache ...@@ -26,7 +27,7 @@ class VertexDeclarationCache
VertexDeclarationCache(); VertexDeclarationCache();
~VertexDeclarationCache(); ~VertexDeclarationCache();
gl::Error applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], gl::ProgramBinary *programBinary, GLsizei instances, GLsizei *repeatDraw); gl::Error applyDeclaration(IDirect3DDevice9 *device, TranslatedAttribute attributes[], gl::Program *program, GLsizei instances, GLsizei *repeatDraw);
void markStateDirty(); void markStateDirty();
......
...@@ -15,7 +15,8 @@ ...@@ -15,7 +15,8 @@
#include "libANGLE/FramebufferAttachment.h" #include "libANGLE/FramebufferAttachment.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/Query.h" #include "libANGLE/Query.h"
#include "libANGLE/ProgramBinary.h" #include "libANGLE/Program.h"
#include "libANGLE/Uniform.h"
#include "libANGLE/TransformFeedback.h" #include "libANGLE/TransformFeedback.h"
#include "libANGLE/VertexArray.h" #include "libANGLE/VertexArray.h"
#include "libANGLE/renderer/BufferImpl.h" #include "libANGLE/renderer/BufferImpl.h"
...@@ -1058,8 +1059,8 @@ static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniform ...@@ -1058,8 +1059,8 @@ static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniform
return false; return false;
} }
gl::ProgramBinary *programBinary = context->getState().getCurrentProgramBinary(); gl::Program *program = context->getState().getProgram();
if (!programBinary) if (!program)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
...@@ -1071,13 +1072,13 @@ static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniform ...@@ -1071,13 +1072,13 @@ static bool ValidateUniformCommonBase(gl::Context *context, GLenum targetUniform
return false; return false;
} }
if (!programBinary->isValidUniformLocation(location)) if (!program->isValidUniformLocation(location))
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
} }
LinkedUniform *uniform = programBinary->getUniformByLocation(location); LinkedUniform *uniform = program->getUniformByLocation(location);
// attempting to write an array to a non-array uniform is an INVALID_OPERATION // attempting to write an array to a non-array uniform is an INVALID_OPERATION
if (uniform->elementCount() == 1 && count > 1) if (uniform->elementCount() == 1 && count > 1)
...@@ -1461,14 +1462,14 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz ...@@ -1461,14 +1462,14 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz
return false; return false;
} }
if (state.getCurrentProgramId() == 0) gl::Program *program = state.getProgram();
if (!program)
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
} }
gl::ProgramBinary *programBinary = state.getCurrentProgramBinary(); if (!program->validateSamplers(NULL, context->getCaps()))
if (!programBinary->validateSamplers(NULL, context->getCaps()))
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
...@@ -1479,7 +1480,7 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz ...@@ -1479,7 +1480,7 @@ static bool ValidateDrawBase(Context *context, GLenum mode, GLsizei count, GLsiz
for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++) for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{ {
const VertexAttribute &attrib = vao->getVertexAttribute(attributeIndex); const VertexAttribute &attrib = vao->getVertexAttribute(attributeIndex);
bool attribActive = (programBinary->getSemanticIndex(attributeIndex) != -1); bool attribActive = (program->getSemanticIndex(attributeIndex) != -1);
if (attribActive && attrib.enabled) if (attribActive && attrib.enabled)
{ {
gl::Buffer *buffer = attrib.buffer.get(); gl::Buffer *buffer = attrib.buffer.get();
...@@ -1573,13 +1574,13 @@ static bool ValidateDrawInstancedANGLE(Context *context) ...@@ -1573,13 +1574,13 @@ static bool ValidateDrawInstancedANGLE(Context *context)
// Verify there is at least one active attribute with a divisor of zero // Verify there is at least one active attribute with a divisor of zero
const gl::State& state = context->getState(); const gl::State& state = context->getState();
gl::ProgramBinary *programBinary = state.getCurrentProgramBinary(); gl::Program *program = state.getProgram();
const VertexArray *vao = state.getVertexArray(); const VertexArray *vao = state.getVertexArray();
for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++) for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{ {
const VertexAttribute &attrib = vao->getVertexAttribute(attributeIndex); const VertexAttribute &attrib = vao->getVertexAttribute(attributeIndex);
bool active = (programBinary->getSemanticIndex(attributeIndex) != -1); bool active = (program->getSemanticIndex(attributeIndex) != -1);
if (active && attrib.divisor == 0) if (active && attrib.divisor == 0)
{ {
return true; return true;
...@@ -1886,14 +1887,7 @@ bool ValidateGetUniformBase(Context *context, GLuint program, GLint location) ...@@ -1886,14 +1887,7 @@ bool ValidateGetUniformBase(Context *context, GLuint program, GLint location)
return false; return false;
} }
gl::ProgramBinary *programBinary = programObject->getProgramBinary(); if (!programObject->isValidUniformLocation(location))
if (!programBinary)
{
context->recordError(Error(GL_INVALID_OPERATION));
return false;
}
if (!programBinary->isValidUniformLocation(location))
{ {
context->recordError(Error(GL_INVALID_OPERATION)); context->recordError(Error(GL_INVALID_OPERATION));
return false; return false;
...@@ -1921,10 +1915,9 @@ static bool ValidateSizedGetUniform(Context *context, GLuint program, GLint loca ...@@ -1921,10 +1915,9 @@ static bool ValidateSizedGetUniform(Context *context, GLuint program, GLint loca
gl::Program *programObject = context->getProgram(program); gl::Program *programObject = context->getProgram(program);
ASSERT(programObject); ASSERT(programObject);
gl::ProgramBinary *programBinary = programObject->getProgramBinary();
// sized queries -- ensure the provided buffer is large enough // sized queries -- ensure the provided buffer is large enough
LinkedUniform *uniform = programBinary->getUniformByLocation(location); LinkedUniform *uniform = programObject->getUniformByLocation(location);
size_t requiredBytes = VariableExternalSize(uniform->type); size_t requiredBytes = VariableExternalSize(uniform->type);
if (static_cast<size_t>(bufSize) < requiredBytes) if (static_cast<size_t>(bufSize) < requiredBytes)
{ {
......
...@@ -74,8 +74,6 @@ ...@@ -74,8 +74,6 @@
'libANGLE/ImageIndex.cpp', 'libANGLE/ImageIndex.cpp',
'libANGLE/Program.cpp', 'libANGLE/Program.cpp',
'libANGLE/Program.h', 'libANGLE/Program.h',
'libANGLE/ProgramBinary.cpp',
'libANGLE/ProgramBinary.h',
'libANGLE/Query.cpp', 'libANGLE/Query.cpp',
'libANGLE/Query.h', 'libANGLE/Query.h',
'libANGLE/RefCountObject.cpp', 'libANGLE/RefCountObject.cpp',
......
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