]> git.tdb.fi Git - libs/gl.git/blob - source/programdata.cpp
Rewrite ProgramData update in a more efficient way
[libs/gl.git] / source / programdata.cpp
1 #include <msp/core/maputils.h>
2 #include <msp/gl/extensions/arb_direct_state_access.h>
3 #include "buffer.h"
4 #include "color.h"
5 #include "error.h"
6 #include "matrix.h"
7 #include "program.h"
8 #include "programdata.h"
9 #include "uniform.h"
10 #include "uniformblock.h"
11 #include "vector.h"
12
13 using namespace std;
14
15 namespace Msp {
16 namespace GL {
17
18 ProgramData::ProgramData(const Program *p):
19         tied_program(p),
20         last_block(0),
21         buffer(0),
22         dirty(0)
23 { }
24
25 // Blocks are intentionally left uncopied
26 ProgramData::ProgramData(const ProgramData &other):
27         tied_program(0),
28         uniforms(other.uniforms),
29         last_block(0),
30         buffer(0),
31         dirty(0)
32 {
33         for(vector<NamedUniform>::iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
34                 i->value = i->value->clone();
35 }
36
37 ProgramData &ProgramData::operator=(const ProgramData &other)
38 {
39         tied_program = other.tied_program;
40
41         uniforms = other.uniforms;
42         for(vector<NamedUniform>::iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
43                 i->value = i->value->clone();
44
45         for(BlockMap::iterator i=blocks.begin(); i!=blocks.end(); ++i)
46                 delete i->second.block;
47         programs.clear();
48
49         last_block = 0;
50         buffer = 0;
51         dirty = 0;
52
53         return *this;
54 }
55
56 ProgramData::~ProgramData()
57 {
58         for(vector<NamedUniform>::iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
59                 delete i->value;
60         for(BlockMap::iterator i=blocks.begin(); i!=blocks.end(); ++i)
61         {
62                 if(i->second.indices.type_flag==0xFE)
63                         delete i->second.indices.dynamic.values;
64                 delete i->second.block;
65         }
66         delete buffer;
67 }
68
69 void ProgramData::uniform(const string &name, Uniform *uni)
70 {
71         try
72         {
73                 if(tied_program)
74                         tied_program->get_uniform_info(name);
75                 else if(name[name.size()-1]==']')
76                         throw invalid_argument("ProgramData::uniform");
77         }
78         catch(...)
79         {
80                 delete uni;
81                 throw;
82         }
83
84         int i = find_uniform_index(name);
85         if(i>=0)
86         {
87                 uniforms[i].replace_value(uni);
88
89                 if(static_cast<unsigned>(i)<MASK_BITS)
90                         dirty |= 1<<i;
91                 else  // Force a full update if the mask isn't wide enough
92                         dirty = ALL_ONES;
93
94                 return;
95         }
96
97         vector<NamedUniform>::iterator j = lower_bound(uniforms.begin(), uniforms.end(), name, uniform_name_compare);
98
99         NamedUniform nu;
100         nu.name = name;
101         nu.value = uni;
102         uniforms.insert(j, nu);
103
104         dirty = ALL_ONES;
105 }
106
107 void ProgramData::uniform(const string &name, const Uniform &u)
108 {
109         uniform(name, u.clone());
110 }
111
112 void ProgramData::uniform(const string &name, int v)
113 {
114         uniform(name, new Uniform1i(v));
115 }
116
117 void ProgramData::uniform(const string &name, float v)
118 {
119         uniform(name, new Uniform1f(v));
120 }
121
122 void ProgramData::uniform(const string &name, int v0, int v1)
123 {
124         int va[2] = { v0, v1 };
125         uniform2(name, va);
126 }
127
128 void ProgramData::uniform(const string &name, float v0, float v1)
129 {
130         float va[2] = { v0, v1 };
131         uniform2(name, va);
132 }
133
134 void ProgramData::uniform2(const string &name, const int *v)
135 {
136         uniform(name, new Uniform2i(v));
137 }
138
139 void ProgramData::uniform2(const string &name, const float *v)
140 {
141         uniform(name, new Uniform2f(v));
142 }
143
144 void ProgramData::uniform(const string &name, int v0, int v1, int v2)
145 {
146         int va[3] = { v0, v1, v2 };
147         uniform3(name, va);
148 }
149
150 void ProgramData::uniform(const string &name, float v0, float v1, float v2)
151 {
152         float va[3] = { v0, v1, v2 };
153         uniform3(name, va);
154 }
155
156 void ProgramData::uniform(const string &name, const Vector3 &v)
157 {
158         uniform(name, v.x, v.y, v.z);
159 }
160
161 void ProgramData::uniform3(const string &name, const int *v)
162 {
163         uniform(name, new Uniform3i(v));
164 }
165
166 void ProgramData::uniform3(const string &name, const float *v)
167 {
168         uniform(name, new Uniform3f(v));
169 }
170
171 void ProgramData::uniform(const string &name, int v0, int v1, int v2, int v3)
172 {
173         int va[4] = { v0, v1, v2, v3 };
174         uniform4(name, va);
175 }
176
177 void ProgramData::uniform(const string &name, float v0, float v1, float v2, float v3)
178 {
179         float va[4] = { v0, v1, v2, v3 };
180         uniform4(name, va);
181 }
182
183 void ProgramData::uniform(const string &name, const Vector4 &v)
184 {
185         uniform(name, v.x, v.y, v.z, v.w);
186 }
187
188 void ProgramData::uniform(const string &name, const Color &c)
189 {
190         uniform(name, c.r, c.g, c.b, c.a);
191 }
192
193 void ProgramData::uniform4(const string &name, const int *v)
194 {
195         uniform(name, new Uniform4i(v));
196 }
197
198 void ProgramData::uniform4(const string &name, const float *v)
199 {
200         uniform(name, new Uniform4f(v));
201 }
202
203 void ProgramData::uniform(const string &name, const LinAl::Matrix<float, 2, 2> &m)
204 {
205         uniform_matrix2(name, &m(0, 0));
206 }
207
208 void ProgramData::uniform_matrix2(const string &name, const float *v)
209 {
210         uniform(name, new UniformMatrix2x2f(v));
211 }
212
213 void ProgramData::uniform(const string &name, const LinAl::Matrix<float, 3, 3> &m)
214 {
215         uniform_matrix3(name, &m(0, 0));
216 }
217
218 void ProgramData::uniform_matrix3(const string &name, const float *v)
219 {
220         uniform(name, new UniformMatrix3x3f(v));
221 }
222
223 void ProgramData::uniform(const string &name, const Matrix &m)
224 {
225         uniform_matrix4(name, m.data());
226 }
227
228 void ProgramData::uniform_matrix4(const string &name, const float *v)
229 {
230         uniform(name, new UniformMatrix4x4f(v));
231 }
232
233 void ProgramData::uniform1_array(const string &name, unsigned n, const int *v)
234 {
235         uniform(name, new UniformArray<Uniform1i>(n, v));
236 }
237
238 void ProgramData::uniform1_array(const string &name, unsigned n, const float *v)
239 {
240         uniform(name, new UniformArray<Uniform1f>(n, v));
241 }
242
243 void ProgramData::uniform2_array(const string &name, unsigned n, const int *v)
244 {
245         uniform(name, new UniformArray<Uniform2i>(n, v));
246 }
247
248 void ProgramData::uniform2_array(const string &name, unsigned n, const float *v)
249 {
250         uniform(name, new UniformArray<Uniform2f>(n, v));
251 }
252
253 void ProgramData::uniform3_array(const string &name, unsigned n, const int *v)
254 {
255         uniform(name, new UniformArray<Uniform3i>(n, v));
256 }
257
258 void ProgramData::uniform3_array(const string &name, unsigned n, const float *v)
259 {
260         uniform(name, new UniformArray<Uniform3f>(n, v));
261 }
262
263 void ProgramData::uniform4_array(const string &name, unsigned n, const int *v)
264 {
265         uniform(name, new UniformArray<Uniform4i>(n, v));
266 }
267
268 void ProgramData::uniform4_array(const string &name, unsigned n, const float *v)
269 {
270         uniform(name, new UniformArray<Uniform4f>(n, v));
271 }
272
273 void ProgramData::uniform_matrix2_array(const string &name, unsigned n, const float *v)
274 {
275         uniform(name, new UniformArray<UniformMatrix2x2f>(n, v));
276 }
277
278 void ProgramData::uniform_matrix3_array(const string &name, unsigned n, const float *v)
279 {
280         uniform(name, new UniformArray<UniformMatrix3x3f>(n, v));
281 }
282
283 void ProgramData::uniform_matrix4_array(const string &name, unsigned n, const float *v)
284 {
285         uniform(name, new UniformArray<UniformMatrix4x4f>(n, v));
286 }
287
288 void ProgramData::remove_uniform(const string &name)
289 {
290         vector<NamedUniform>::const_iterator i = lower_bound(uniforms.begin(), uniforms.end(), name, uniform_name_compare);
291         if(i==uniforms.end() || i->name!=name)
292                 return;
293
294         delete i->value;
295         uniforms.erase(i);
296
297         dirty = ALL_ONES;
298 }
299
300 vector<string> ProgramData::get_uniform_names() const
301 {
302         vector<string> names;
303         names.reserve(uniforms.size());
304         for(vector<NamedUniform>::const_iterator i=uniforms.begin(); i!=uniforms.end(); ++i)
305                 names.push_back(i->name);
306         return names;
307 }
308
309 const Uniform &ProgramData::get_uniform(const string &name) const
310 {
311         int i = find_uniform_index(name);
312         if(i<0)
313                 throw key_error(name);
314         return *uniforms[i].value;
315 }
316
317 bool ProgramData::uniform_name_compare(const NamedUniform &nu, const string &name)
318 {
319         return nu.name<name;
320 }
321
322 int ProgramData::find_uniform_index(const string &name) const
323 {
324         vector<NamedUniform>::const_iterator i = lower_bound(uniforms.begin(), uniforms.end(), name, uniform_name_compare);
325         return ((i!=uniforms.end() && i->name==name) ? i-uniforms.begin() : -1);
326 }
327
328 void ProgramData::update_block_uniform_indices(SharedBlock &block, const Program::UniformBlockInfo &info) const
329 {
330         UInt8 *indices = block.indices.values;
331         if(info.uniforms.size()>16)
332         {
333                 if(block.indices.type_flag==0xFD)
334                 {
335                         block.indices.dynamic.values = new UInt8[info.uniforms.size()];
336                         block.indices.type_flag = 0xFE;
337                 }
338                 indices = block.indices.dynamic.values;
339         }
340
341         block.used = 0;
342         for(unsigned i=0; i<info.uniforms.size(); ++i)
343         {
344                 int j = find_uniform_index(info.uniforms[i]->name);
345                 if(j>=0)
346                 {
347                         indices[i] = j;
348                         if(static_cast<unsigned>(j)<MASK_BITS)
349                                 block.used |= 1<<j;
350                 }
351                 else
352                         indices[i] = 0xFF;
353         }
354
355         block.dirty = block.used;
356 }
357
358 void ProgramData::update_block(SharedBlock &block, const Program::UniformBlockInfo &info) const
359 {
360         const UInt8 *indices = block.get_uniform_indices();
361         for(unsigned i=0; i<info.uniforms.size(); ++i)
362                 if(indices[i]!=0xFF)
363                         block.block->attach(*info.uniforms[i], *uniforms[indices[i]].value);
364 }
365
366 ProgramData::SharedBlock *ProgramData::get_shared_block(const Program::UniformBlockInfo &info) const
367 {
368         BlockMap::iterator i = blocks.find(info.layout_hash);
369         if(i==blocks.end())
370         {
371                 bool any_found = false;
372                 for(vector<const Program::UniformInfo *>::const_iterator j=info.uniforms.begin(); (!any_found && j!=info.uniforms.end()); ++j)
373                         any_found = (find_uniform_index((*j)->name)>=0);
374
375                 // TODO throw if all uniforms for a buffer-backed block are not found
376                 if(!any_found)
377                         return 0;
378
379                 UniformBlock *block;
380                 if(info.bind_point>=0)
381                 {
382                         if(!buffer)
383                         {
384                                 buffer = new Buffer(UNIFORM_BUFFER);
385                                 buffer->set_usage(STREAM_DRAW);
386                         }
387
388                         block = new UniformBlock(info.data_size);
389                         block->use_buffer(buffer, last_block);
390                         last_block = block;
391                 }
392                 else
393                         block = new UniformBlock;
394
395                 i = blocks.insert(BlockMap::value_type(info.layout_hash, SharedBlock(block))).first;
396                 update_block_uniform_indices(i->second, info);
397         }
398
399         return &i->second;
400 }
401
402 void ProgramData::apply() const
403 {
404         const Program *prog = Program::current();
405         if(!prog)
406                 throw invalid_operation("ProgramData::apply");
407
408         Program::LayoutHash layout = prog->get_uniform_layout_hash();
409         ProgramUniforms &pu = programs[layout];
410
411         Mask force_dirty = (dirty==ALL_ONES ? ALL_ONES : 0U);
412         Mask affected = (dirty&pu.used) | force_dirty;
413         if(affected|pu.dirty)
414         {
415                 /* If the global dirty flag affects this program, add it to per-program
416                 dirty flags and clear the global flag.  A previously unseen program will
417                 always cause this to happen. */
418                 if(affected)
419                 {
420                         for(BlockMap::iterator i=blocks.begin(); i!=blocks.end(); ++i)
421                                 i->second.dirty |= (dirty&i->second.used) | force_dirty;
422                         for(ProgramMap::iterator i=programs.begin(); i!=programs.end(); ++i)
423                                 i->second.dirty |= (dirty&i->second.used) | force_dirty;
424                         dirty = 0;
425                 }
426
427                 const Program::UniformBlockMap &prog_blocks = prog->get_uniform_blocks();
428
429                 if(pu.dirty==ALL_ONES)
430                 {
431                         /* The set of uniforms has changed since this program was last used.
432                         Regenerate the list of uniform blocks. */
433                         pu.blocks.clear();
434                         pu.blocks.reserve(prog_blocks.size());
435
436                         pu.used = 0;
437                         for(Program::UniformBlockMap::const_iterator i=prog_blocks.begin(); i!=prog_blocks.end(); ++i)
438                         {
439                                 SharedBlock *shared = get_shared_block(i->second);
440                                 if(shared)
441                                 {
442                                         if(shared->dirty==ALL_ONES)
443                                                 update_block_uniform_indices(*shared, i->second);
444                                         pu.used |= shared->used;
445                                 }
446
447                                 pu.blocks.push_back(ProgramBlock(i->second.bind_point, shared));
448                         }
449                 }
450
451                 // Update the contents of all dirty blocks.
452                 bool buffered_blocks_updated = false;
453                 std::vector<ProgramBlock>::iterator j = pu.blocks.begin();
454                 for(Program::UniformBlockMap::const_iterator i=prog_blocks.begin(); i!=prog_blocks.end(); ++i, ++j)
455                 {
456                         if(!j->shared || !j->shared->dirty)
457                                 continue;
458
459                         update_block(*j->shared, i->second);
460                         j->shared->dirty = 0;
461                         buffered_blocks_updated |= (j->bind_point>=0);
462                 }
463
464                 pu.dirty = 0;
465
466                 /* If any blocks stored in the buffer were updated, bind the buffer here
467                 to avoid state thrashing. */
468                 if(buffered_blocks_updated && !ARB_direct_state_access)
469                         buffer->bind();
470         }
471
472         for(vector<ProgramBlock>::iterator i=pu.blocks.begin(); i!=pu.blocks.end(); ++i)
473                 if(i->block)
474                         i->block->apply(i->bind_point);
475 }
476
477
478 ProgramData::NamedUniform::NamedUniform():
479         value(0)
480 { }
481
482 void ProgramData::NamedUniform::replace_value(Uniform *v)
483 {
484         /* UniformBlock does not copy the uniforms, so existing default blocks
485         will be left with stale pointers.  This is not a problem as long as no
486         one stores pointers to the blocks and expects them to stay valid. */
487         delete value;
488         value = v;
489 }
490
491
492 ProgramData::SharedBlock::SharedBlock(UniformBlock *b):
493         used(0),
494         dirty(0),
495         block(b)
496 {
497         indices.type_flag = 0xFD;
498 }
499
500 const UInt8 *ProgramData::SharedBlock::get_uniform_indices() const
501 {
502         return (indices.type_flag==0xFE ? indices.dynamic.values : indices.values);
503 }
504
505
506 ProgramData::ProgramBlock::ProgramBlock():
507         bind_point(-1),
508         block(0),
509         shared(0)
510 { }
511
512 ProgramData::ProgramBlock::ProgramBlock(int p, SharedBlock *b):
513         bind_point(p),
514         block((b && b->used) ? b->block : 0),
515         shared(b)
516 { }
517
518
519 ProgramData::ProgramUniforms::ProgramUniforms():
520         used(ALL_ONES),
521         dirty(ALL_ONES)
522 { }
523
524
525 ProgramData::Loader::Loader(ProgramData &pd):
526         DataFile::ObjectLoader<ProgramData>(pd)
527 {
528         add("uniform", &Loader::uniform1i);
529         add("uniform1i", &Loader::uniform1i);
530         add("uniform", &Loader::uniform1f);
531         add("uniform1f", &Loader::uniform1f);
532         add("uniform", &Loader::uniform2i);
533         add("uniform2i", &Loader::uniform2i);
534         add("uniform", &Loader::uniform2f);
535         add("uniform2f", &Loader::uniform2f);
536         add("uniform", &Loader::uniform3i);
537         add("uniform3i", &Loader::uniform3i);
538         add("uniform", &Loader::uniform3f);
539         add("uniform3f", &Loader::uniform3f);
540         add("uniform", &Loader::uniform4i);
541         add("uniform4i", &Loader::uniform4i);
542         add("uniform", &Loader::uniform4f);
543         add("uniform4f", &Loader::uniform4f);
544         add("uniform1i_array", &Loader::uniform1i_array);
545         add("uniform1f_array", &Loader::uniform1f_array);
546         add("uniform2f_array", &Loader::uniform2f_array);
547         add("uniform3f_array", &Loader::uniform3f_array);
548         add("uniform4f_array", &Loader::uniform4f_array);
549         add("uniform_array", &Loader::uniform_array);
550 }
551
552 void ProgramData::Loader::uniform1i(const string &n, int v)
553 {
554         obj.uniform(n, v);
555 }
556
557 void ProgramData::Loader::uniform1f(const string &n, float v)
558 {
559         obj.uniform(n, v);
560 }
561
562 void ProgramData::Loader::uniform2i(const string &n, int v0, int v1)
563 {
564         obj.uniform(n, v0, v1);
565 }
566
567 void ProgramData::Loader::uniform2f(const string &n, float v0, float v1)
568 {
569         obj.uniform(n, v0, v1);
570 }
571
572 void ProgramData::Loader::uniform3i(const string &n, int v0, int v1, int v2)
573 {
574         obj.uniform(n, v0, v1, v2);
575 }
576
577 void ProgramData::Loader::uniform3f(const string &n, float v0, float v1, float v2)
578 {
579         obj.uniform(n, v0, v1, v2);
580 }
581
582 void ProgramData::Loader::uniform4i(const string &n, int v0, int v1, int v2, int v3)
583 {
584         obj.uniform(n, v0, v1, v2, v3);
585 }
586
587 void ProgramData::Loader::uniform4f(const string &n, float v0, float v1, float v2, float v3)
588 {
589         obj.uniform(n, v0, v1, v2, v3);
590 }
591
592 void ProgramData::Loader::uniform_array_(const string &n, DataType t, unsigned e)
593 {
594         ArrayLoader ldr(t, e);
595         load_sub_with(ldr);
596         unsigned size = ldr.get_size();
597         if(!size)
598                 throw logic_error("empty uniform array");
599
600         DataType type = ldr.get_data_type();
601         unsigned elem_size = ldr.get_element_size();
602         if(type==INT)
603         {
604                 const int *data = reinterpret_cast<const int *>(ldr.get_data());
605                 if(elem_size==1)
606                         obj.uniform1_array(n, size, data);
607                 else if(elem_size==2)
608                         obj.uniform2_array(n, size, data);
609                 else if(elem_size==3)
610                         obj.uniform3_array(n, size, data);
611                 else if(elem_size==4)
612                         obj.uniform4_array(n, size, data);
613                 else
614                         throw logic_error("unsupported combination of array type and element size");
615         }
616         else if(type==FLOAT)
617         {
618                 const float *data = reinterpret_cast<const float *>(ldr.get_data());
619                 if(elem_size==1)
620                         obj.uniform1_array(n, size, data);
621                 else if(elem_size==2)
622                         obj.uniform2_array(n, size, data);
623                 else if(elem_size==3)
624                         obj.uniform3_array(n, size, data);
625                 else if(elem_size==4)
626                         obj.uniform4_array(n, size, data);
627                 else
628                         throw logic_error("unsupported combination of array type and element size");
629         }
630         else
631                 throw logic_error("unsupported array type");
632 }
633
634 void ProgramData::Loader::uniform1i_array(const string &n)
635 {
636         uniform_array_(n, INT, 1);
637 }
638
639 void ProgramData::Loader::uniform1f_array(const string &n)
640 {
641         uniform_array_(n, FLOAT, 1);
642 }
643
644 void ProgramData::Loader::uniform2i_array(const string &n)
645 {
646         uniform_array_(n, INT, 2);
647 }
648
649 void ProgramData::Loader::uniform2f_array(const string &n)
650 {
651         uniform_array_(n, FLOAT, 2);
652 }
653
654 void ProgramData::Loader::uniform3i_array(const string &n)
655 {
656         uniform_array_(n, INT, 3);
657 }
658
659 void ProgramData::Loader::uniform3f_array(const string &n)
660 {
661         uniform_array_(n, FLOAT, 3);
662 }
663
664 void ProgramData::Loader::uniform4i_array(const string &n)
665 {
666         uniform_array_(n, INT, 4);
667 }
668
669 void ProgramData::Loader::uniform4f_array(const string &n)
670 {
671         uniform_array_(n, FLOAT, 4);
672 }
673
674 void ProgramData::Loader::uniform_array(const string &n)
675 {
676         uniform_array_(n, static_cast<DataType>(0), 0);
677 }
678
679
680 ProgramData::ArrayLoader::ArrayLoader(DataType t, unsigned e):
681         type(t),
682         element_size(e)
683 {
684         add("uniform", &ArrayLoader::uniform1i);
685         add("uniform1i", &ArrayLoader::uniform1i);
686         add("uniform", &ArrayLoader::uniform1f);
687         add("uniform1f", &ArrayLoader::uniform1f);
688         add("uniform", &ArrayLoader::uniform2f);
689         add("uniform2f", &ArrayLoader::uniform2f);
690         add("uniform", &ArrayLoader::uniform3f);
691         add("uniform3f", &ArrayLoader::uniform3f);
692         add("uniform", &ArrayLoader::uniform4f);
693         add("uniform4f", &ArrayLoader::uniform4f);
694 }
695
696 void ProgramData::ArrayLoader::uniform(DataType t, unsigned e, const void *v)
697 {
698         if(element_size && (t!=type || e!=element_size))
699                 throw logic_error("heterogeneous array contents");
700
701         if(!element_size)
702         {
703                 type = t;
704                 element_size = e;
705         }
706
707         const char *cv = reinterpret_cast<const char *>(v);
708         data.insert(data.end(), cv, cv+element_size*4);
709 }
710
711 void ProgramData::ArrayLoader::uniform1i(int v)
712 {
713         uniform(INT, 1, &v);
714 }
715
716 void ProgramData::ArrayLoader::uniform1f(float v)
717 {
718         uniform(FLOAT, 1, &v);
719 }
720
721 void ProgramData::ArrayLoader::uniform2i(int v0, int v1)
722 {
723         int va[2] = { v0, v1 };
724         uniform(INT, 2, va);
725 }
726
727 void ProgramData::ArrayLoader::uniform2f(float v0, float v1)
728 {
729         float va[2] = { v0, v1 };
730         uniform(FLOAT, 2, va);
731 }
732
733 void ProgramData::ArrayLoader::uniform3i(int v0, int v1, int v2)
734 {
735         int va[3] = { v0, v1, v2 };
736         uniform(INT, 3, va);
737 }
738
739 void ProgramData::ArrayLoader::uniform3f(float v0, float v1, float v2)
740 {
741         float va[3] = { v0, v1, v2 };
742         uniform(FLOAT, 3, va);
743 }
744
745 void ProgramData::ArrayLoader::uniform4i(int v0, int v1, int v2, int v3)
746 {
747         int va[4] = { v0, v1, v2, v3 };
748         uniform(INT, 4, va);
749 }
750
751 void ProgramData::ArrayLoader::uniform4f(float v0, float v1, float v2, float v3)
752 {
753         float va[4] = { v0, v1, v2, v3 };
754         uniform(FLOAT, 4, va);
755 }
756
757 } // namespace GL
758 } // namespace Msp