Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(431)

Unified Diff: gpu/command_buffer/service/program_manager.h

Issue 1309743005: command_buffer: Implement EXT_blend_func_extended (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new-05-path-fragment-input-gen
Patch Set: address review comments Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 6cdb2007732a42e618da98e5fb176271b047fe28..06ffab451fcf561f015d054738c2768323e9d1d8 100644
--- a/gpu/command_buffer/service/program_manager.h
+++ b/gpu/command_buffer/service/program_manager.h
@@ -20,6 +20,7 @@
namespace gpu {
namespace gles2 {
+class FeatureInfo;
class ProgramCache;
class ProgramManager;
class Shader;
@@ -78,6 +79,27 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
GLint location;
std::string name;
};
+ struct ProgramOutputInfo {
+ ProgramOutputInfo(GLsizei _size,
+ GLenum _type,
+ GLint _colorName,
+ GLuint _index,
+ const std::string& _name)
+ : size(_size),
+ type(_type),
+ colorName(_colorName),
+ index(_index),
+ name(_name) {}
+
+ ProgramOutputInfo() : size(-1), type(GL_NONE), colorName(-1), index(-1) {}
Zhenyao Mo 2015/09/30 00:23:48 index is GLuint, so init it to -1 is confusing.
Kimmo Kinnunen 2015/10/08 13:18:12 Done.
+ bool IsValid() const { return colorName != -1; }
Zhenyao Mo 2015/09/30 00:23:48 I think you should declare colorName also as GLuin
Kimmo Kinnunen 2015/10/08 13:18:12 Done.
+
+ GLsizei size;
+ GLenum type;
+ GLint colorName;
+ GLuint index;
+ std::string name;
+ };
struct UniformInfo {
UniformInfo();
@@ -121,8 +143,10 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
typedef std::vector<UniformInfo> UniformInfoVector;
typedef std::vector<VertexAttrib> AttribInfoVector;
typedef std::vector<FragmentInputInfo> FragmentInputInfoVector;
+ typedef std::vector<ProgramOutputInfo> ProgramOutputInfoVector;
typedef std::vector<int> SamplerIndices;
typedef std::map<std::string, GLint> LocationMap;
+ typedef std::map<std::string, std::pair<GLuint, GLuint>> LocationIndexMap;
typedef std::vector<std::string> StringVector;
Program(ProgramManager* manager, GLuint service_id);
@@ -181,6 +205,10 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
const UniformInfo* GetUniformInfoByFakeLocation(
GLint fake_location, GLint* real_location, GLint* array_index) const;
+ // Gets the ProgramOutputInfo of a fragment output by name.
+ const ProgramOutputInfo* GetProgramOutputInfo(
+ const std::string& original_name) const;
+
// Gets all the program info.
void GetProgramInfo(
ProgramManager* manager, CommonDecoder::Bucket* bucket) const;
@@ -198,6 +226,14 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
// glGetProgramInfoCHROMIUM.
bool GetUniformsES3(CommonDecoder::Bucket* bucket) const;
+ // Returns the fragment shader output variable color name binding.
+ // Returns -1 if |original_name| is not an out variable or error.
+ GLint GetFragDataLocation(const std::string& original_name) const;
+
+ // Returns the fragment shader output variable color index binding.
+ // Returns -1 if |original_name| is not an out variable or error.
+ GLint GetFragDataIndex(const std::string& original_name) const;
+
// Sets the sampler values for a uniform.
// This is safe to call for any location. If the location is not
// a sampler uniform nothing will happen.
@@ -255,7 +291,13 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
// Sets fragment input-location binding from a
// glBindFragmentInputLocationCHROMIUM() call.
- bool SetFragmentInputLocationBinding(const std::string& name, GLint location);
+ bool SetFragmentInputLocationBinding(const std::string& original_name,
+ GLint location);
+
+ // Sets program output variable location and color index.
+ bool SetProgramOutputLocationBinding(const std::string& name,
+ GLuint colorName,
+ GLuint index = 0);
Zhenyao Mo 2015/09/30 00:23:48 Chromium coding style doesn't allow default argume
Kimmo Kinnunen 2015/10/08 13:18:12 Done.
// Detects if there are attribute location conflicts from
// glBindAttribLocation() calls.
@@ -282,6 +324,11 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
// We only consider the statically used fragment inputs in the program.
bool DetectFragmentInputLocationBindingConflicts() const;
+ // Detects if there are program output location conflicts from
+ // glBindFragDataLocation and ..LocationIndexedEXT calls.
+ // We only consider the statically used program outputs in the program.
+ bool DetectProgramOutputLocationBindingConflicts() const;
+
// Return true if any built-in invariant matching rules are broken as in
// GLSL ES spec 1.00.17, section 4.6.4, Invariance and Linkage.
bool DetectBuiltInInvariantConflicts() const;
@@ -363,12 +410,19 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
// Returns false upon failure.
bool ExecuteTransformFeedbackVaryingsCall();
+ void ExecuteProgramOutputBindCalls();
+
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);
- enum VariableInfoType { kUniformVariableInfo, kVaryingVariableInfo };
+ enum VariableInfoType {
+ kUniformVariableInfo,
+ kFragmentInputVariableInfo,
+ kProgramOutputVariableInfo
+ };
+
// Query uniform or varying 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
@@ -427,6 +481,8 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
FragmentInputInfoVector fragment_input_infos_;
+ ProgramOutputInfoVector program_output_infos_;
+
// The program this Program is tracking.
GLuint service_id_;
@@ -466,6 +522,10 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
// Fragment input-location binding map from
// glBindFragmentInputLocationCHROMIUM() calls.
LocationMap bind_fragment_input_location_map_;
+
+ // output variable - (location,index) binding map from
+ // glBindFragDataLocation() and ..IndexedEXT() calls.
+ LocationIndexMap bind_program_output_location_index_map_;
};
// Tracks the Programs.
@@ -476,6 +536,7 @@ class GPU_EXPORT ProgramManager {
public:
explicit ProgramManager(ProgramCache* program_cache,
uint32 max_varying_vectors,
+ uint32 max_dual_source_draw_buffers,
FeatureInfo* feature_info);
~ProgramManager();
@@ -506,8 +567,9 @@ class GPU_EXPORT ProgramManager {
// Clears the uniforms for this program.
void ClearUniforms(Program* program);
- // Returns true if prefix is invalid for gl.
- static bool IsInvalidPrefix(const char* name, size_t length);
+ // Returns true if |name| has a prefix that is intended for GL built-in shader
+ // variables.
+ static bool HasBuiltInPrefix(const std::string& name);
// Check if a Program is owned by this ProgramManager.
bool IsOwned(Program* program) const;
@@ -518,6 +580,10 @@ class GPU_EXPORT ProgramManager {
return max_varying_vectors_;
}
+ uint32 max_dual_source_draw_buffers() const {
+ return max_dual_source_draw_buffers_;
+ }
+
private:
friend class Program;
@@ -544,6 +610,7 @@ class GPU_EXPORT ProgramManager {
ProgramCache* program_cache_;
uint32 max_varying_vectors_;
+ uint32 max_dual_source_draw_buffers_;
scoped_refptr<FeatureInfo> feature_info_;

Powered by Google App Engine
This is Rietveld 408576698