<div dir="ltr"><div>Hi Brecht, thanks for the work!<br><br>A few improvements, if I may:<br><br></div><div>* Transform is no different than a GPUShaderParam now. One can easily think of UI shaders where we just work with 2D coordinates<br><br></div><div>* As Ton said above, not all input, such as basic color, comes through vertex buffers. We need a way to set a constant state for an attribute. This is easily supported in GL by glAttribute* calls (which are not deprecated :) ).<br><br></div><div>* Passing all parameters to the shader like that:<br><br><pre class="">draw<span class="">(</span>shader, params, vertex_buffers, transformation<span class="">)</span><span class="">;</span></pre>Still feels bound to a certain implementation/assumptions. What we would like, imo, is a way for the shader type itself to advertise its inputs, then client code connect data to those inputs as it wishes.<br><br></div><div>This can be achieved with a two layer system:<br></div><div>We have a low level shader compilation, binding, etc system, and we have a use-case-specific shader interface which sits on top of it.<br><br></div><div>So the whole workflow looks something like that:<br><br><br></div><div>1) compile shader<br></div><div>2) client code obtains input slots (attributes, textures, uniforms) from a use-case specific interface.<br></div><div>For instance, for a lighted mesh, client code can request a specific &quot;light&quot; struct from the inteface.<br></div><div>This can be set to the shader through glUniform calls or by using a uniform buffer etc, etc by the inteface. It is of little matter to the user.<br></div><div>Client code needs to set if attributes come from vertex buffers or constants, which can be easily set if GLVertexAttrib struct has some extra state.<br></div><div>3) Interface objects can be cached and reused.<br></div><div>4) draw call sequence is now:<br></div><div><br>----------------------<br></div><div>shader-&gt;compile()<br><br></div><div>/* gets relevant indices for attributes, uniform blocks etc, needs to happen just once after shader compilation */<br></div><div>interface-&gt;aqcuireFromShader(shader);<br><br></div><div>LightParams *lp = interface-&gt;getLightParams();<br></div><div><br></div><div>lp-&gt;light_pos = pos;<br></div><div><br></div><div><div>GPUAttribute *p = interface-&gt;getPositionAttribute();<br></div><br>GPU_bind_vertex_buffer(p, offset, stride, etc...);<br><br>GPUAttribute *n = interface-&gt;getNormalAttribute();<br><br></div><div>GPU_constant_attrib(n, value);<br></div><div><br>/* keep interface for later use, do more stuff */<br>...<br><br><div>/* bind shader */<br></div><div>shader-&gt;bind();<br></div><br></div><div>/* sets attributes appropriately and effectively */<br></div><div>interface-&gt;bind();<br><br></div><div>/* draw */<br></div><div>GPUdraw(numeElements, drawType)<br></div><div>-----------------------------<br><br></div><div>This decouples the low level stuff from the client code stuff quite effectively imo.<br><br></div><div>* For more complex systems, like the node-based shaders (which I hope can be the only display mechanism for the meshes in the future), we need to have a more generic system of course.<br><br></div><div>The current GPU codegen module already has most components there. The only addition to the previous interface based design is that Attribute components, now have an extra field which is about the type of customdata it needs. And our code already does that :). It just needs to set a constant value for meshes that do not have the customdata that are requested available (maybe we already have that? Can&#39;t remember off hand).<br><br></div><div>I think that&#39;s all my input for now.<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On 5 December 2015 at 03:02, Brecht Van Lommel <span dir="ltr">&lt;<a href="mailto:brechtvanlommel@gmail.com" target="_blank">brechtvanlommel@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I&#39;ve written a rough proposal for the low level shader API that all<br>
OpenGL shaders would use, both for mesh and UI drawing.<br>
<a href="http://wiki.blender.org/index.php/Dev:2.8/Source/OpenGL/Shaders" rel="noreferrer" target="_blank">http://wiki.blender.org/index.php/Dev:2.8/Source/OpenGL/Shaders</a><br>
<br>
It builds on data structures and APIs that are already there, moving<br>
information about required vertex attributes from GPUMaterial to<br>
GPUShader, while moving uniform and texture values into a new<br>
GPUShaderParams. Nothing radical really.<br>
<br>
What do you think?<br>
<br>
Thanks,<br>
Brecht.<br>
_______________________________________________<br>
Bf-viewport mailing list<br>
<a href="mailto:Bf-viewport@blender.org">Bf-viewport@blender.org</a><br>
<a href="http://lists.blender.org/mailman/listinfo/bf-viewport" rel="noreferrer" target="_blank">http://lists.blender.org/mailman/listinfo/bf-viewport</a><br>
</blockquote></div><br></div>