Index: gpu/command_buffer/service/program_manager.h |
diff --git a/gpu/command_buffer/service/program_manager.h b/gpu/command_buffer/service/program_manager.h |
index bf02f8037c1503f763757e294b9b5b2010954210..5504e34ae486137b940496d53c8b84f33bfeacc4 100644 |
--- a/gpu/command_buffer/service/program_manager.h |
+++ b/gpu/command_buffer/service/program_manager.h |
@@ -73,15 +73,12 @@ class GPU_EXPORT Program : public base::RefCounted<Program> { |
struct UniformInfo { |
UniformInfo(); |
- UniformInfo( |
- GLsizei _size, GLenum _type, GLint _fake_location_base, |
- const std::string& _name); |
+ UniformInfo(const std::string& client_name, |
+ GLint client_location_base, |
+ GLenum _type, |
+ bool _is_array, |
+ const std::vector<GLint>& service_locations); |
~UniformInfo(); |
- |
- bool IsValid() const { |
- return size != 0; |
- } |
- |
bool IsSampler() const { |
return type == GL_SAMPLER_2D || type == GL_SAMPLER_2D_RECT_ARB || |
type == GL_SAMPLER_CUBE || type == GL_SAMPLER_EXTERNAL_OES; |
@@ -110,7 +107,36 @@ class GPU_EXPORT Program : public base::RefCounted<Program> { |
std::string name; |
}; |
+ class UniformLocationEntry { |
+ public: |
+ UniformLocationEntry() : uniform_(nullptr), inactive_(false) {} |
+ bool IsUnused() const { return !uniform_ && !inactive_; } |
+ bool IsInactive() const { return inactive_; } |
+ bool IsActive() const { return uniform_; } |
+ void SetInactive() { |
+ uniform_ = nullptr; |
+ inactive_ = true; |
+ } |
+ void SetActive(UniformInfo* uniform) { |
+ uniform_ = uniform; |
Zhenyao Mo
2015/11/20 00:15:01
Maybe DCHECK(uniform)?
Kimmo Kinnunen
2015/11/20 07:56:53
Done.
|
+ inactive_ = false; |
+ } |
+ const UniformInfo* uniform() const { |
+ DCHECK(IsActive()); |
+ return uniform_; |
+ } |
+ UniformInfo* uniform() { |
+ DCHECK(IsActive()); |
+ return uniform_; |
+ } |
+ |
+ private: |
+ UniformInfo* uniform_; // Pointer to uniform_info_ vector entry. |
+ bool inactive_; |
+ }; |
+ |
typedef std::vector<UniformInfo> UniformInfoVector; |
+ typedef std::vector<UniformLocationEntry> UniformLocationVector; |
typedef std::vector<VertexAttrib> AttribInfoVector; |
typedef std::vector<FragmentInputInfo> FragmentInputInfoVector; |
typedef std::vector<int> SamplerIndices; |
@@ -172,6 +198,10 @@ class GPU_EXPORT Program : public base::RefCounted<Program> { |
const UniformInfo* GetUniformInfoByFakeLocation( |
GLint fake_location, GLint* real_location, GLint* array_index) const; |
+ // Returns true if |fake_location| is a location for an inactive uniform, |
+ // -1 or bound, non-existing uniform. |
Zhenyao Mo
2015/11/20 00:15:01
nit: or -> for
Kimmo Kinnunen
2015/11/20 07:56:53
Done.
|
+ bool IsInactiveUniformLocationByFakeLocation(GLint fake_location) const; |
+ |
// Gets all the program info. |
void GetProgramInfo( |
ProgramManager* manager, CommonDecoder::Bucket* bucket) const; |
@@ -333,6 +363,7 @@ class GPU_EXPORT Program : public base::RefCounted<Program> { |
// Updates the program info after a successful link. |
void Update(); |
+ void UpdateUniforms(); |
void UpdateFragmentInputs(); |
// Process the program log, replacing the hashed names with original names. |
@@ -355,33 +386,20 @@ class GPU_EXPORT Program : public base::RefCounted<Program> { |
// Returns false upon failure. |
bool ExecuteTransformFeedbackVaryingsCall(); |
- void AddUniformInfo( |
- GLsizei size, GLenum type, GLint location, GLint fake_base_location, |
- const std::string& name, const std::string& original_name, |
- size_t* next_available_index); |
- |
- // Query uniform data returned by ANGLE translator by the mapped name. |
- // Some drivers incorrectly return an uniform name of size-1 array without |
- // "[0]". In this case, we correct the name by appending "[0]" to it. |
- void GetCorrectedUniformData( |
- const std::string& name, |
- std::string* corrected_name, std::string* original_name, |
- GLsizei* size, GLenum* type) const; |
- |
// Query VertexAttrib data returned by ANGLE translator by the mapped name. |
void GetVertexAttribData( |
const std::string& name, std::string* original_name, GLenum* type) const; |
void DetachShaders(ShaderManager* manager); |
- static inline GLint GetUniformInfoIndexFromFakeLocation( |
+ static inline size_t GetUniformLocationIndexFromFakeLocation( |
GLint fake_location) { |
- return fake_location & 0xFFFF; |
+ return static_cast<size_t>(fake_location & 0xFFFF); |
} |
- static inline GLint GetArrayElementIndexFromFakeLocation( |
+ static inline size_t GetArrayElementIndexFromFakeLocation( |
GLint fake_location) { |
- return (fake_location >> 16) & 0xFFFF; |
+ return static_cast<size_t>((fake_location >> 16) & 0xFFFF); |
} |
const FeatureInfo& feature_info() const; |
@@ -402,6 +420,7 @@ class GPU_EXPORT Program : public base::RefCounted<Program> { |
// Uniform info by index. |
UniformInfoVector uniform_infos_; |
+ UniformLocationVector uniform_locations_; |
// The indices of the uniforms that are samplers. |
SamplerIndices sampler_indices_; |
@@ -427,10 +446,6 @@ class GPU_EXPORT Program : public base::RefCounted<Program> { |
// True if the uniforms have been cleared. |
bool uniforms_cleared_; |
- // This is different than uniform_infos_.size() because |
- // that is a sparce array. |
- GLint num_uniforms_; |
- |
// Log info |
scoped_ptr<std::string> log_info_; |