26 : vertex_shader_(kVertexShaderChanged,
ShaderPtr(), this),
27 fragment_shader_(kFragmentShaderChanged,
ShaderPtr(), this),
30 concurrent_set_(false) {
35 if (
Shader* shader = vertex_shader_.Get().Get())
36 shader->RemoveReceiver(
this);
37 if (
Shader* shader = fragment_shader_.Get().Get())
38 shader->RemoveReceiver(
this);
42 const std::string& id_string,
44 const std::string& vertex_shader_string,
45 const std::string& fragment_shader_string,
48 program->SetLabel(id_string);
49 program->SetVertexShader(
51 program->GetVertexShader()->SetLabel(id_string +
" vertex shader");
52 program->SetFragmentShader(
54 program->GetFragmentShader()->SetLabel(id_string +
" fragment shader");
60 if (notifier == vertex_shader_.Get().Get())
62 else if (notifier == fragment_shader_.Get().Get())
68 if (concurrent_set_) {
70 if (value != concurrent_) {
71 LOG(
WARNING) <<
"Shader program resources already created"
72 <<
" - cannot change concurrency" << std::endl;
76 concurrent_set_ =
true;
#define LOG(severity)
Logs the streamed message unconditionally with a severity of severity.
A Notifier both sends notifications to and receives notifications from other Notifiers.
void OnChanged(int bit) const
Forwards OnChanged to all resources.
T * Get() const
Returns a raw pointer to the instance, which may be NULL.
void SetConcurrent(bool value)
Sets/returns whether this shader program should have per-thread state.
base::ReferentPtr< Shader >::Type ShaderPtr
Convenience typedef for shared pointers to Shaders.
static const ShaderProgramPtr BuildFromStrings(const std::string &id_string, const ShaderInputRegistryPtr ®istry_ptr, const std::string &vertex_shader_string, const std::string &fragment_shader_string, const base::AllocatorPtr &allocator)
Convenience function that builds and returns a new ShaderProgram instance that uses the given ShaderI...
A Shader represents an OpenGL shader stage.
int GetResourceCount() const
Returns the number of resources that this holder holds.
ShaderProgram(const ShaderInputRegistryPtr ®istry)
A valid ShaderInputRegistryPtr must be passed to the constructor.
~ShaderProgram() override
The destructor is protected because all base::Referent classes must have protected or private destruc...
A SharedPtr is a smart shared pointer to an instance of some class that implements reference counting...