This patch will use compute shaders to create the VBO for hair. The previous implementation uses transform feedback. Timings before: between 0.000069s and 0.000362s. Timings after: between 0.000032s and 0.000092s. Speedup isn't noticeable by end-users. The patch is used to test the new compute shader pipeline and integrate it with the draw manager. Allowing EEVEE, Workbench and other draw engines to use compute shaders with the introduction of `DRW_shgroup_call_compute` and `DRW_shgroup_vertex_buffer`. Future improvements are possible by generating the index buffer of hair directly on the GPU. NOTE: that compute shaders aren't supported by Apple and still use the transform feedback workaround. Reviewed By: fclem Differential Revision: https://developer.blender.org/D11057
31 lines
749 B
GLSL
31 lines
749 B
GLSL
|
|
/* To be compiled with common_hair_lib.glsl */
|
|
|
|
out vec4 finalColor;
|
|
|
|
#ifdef TF_WORKAROUND
|
|
uniform int targetWidth;
|
|
uniform int targetHeight;
|
|
uniform int idOffset;
|
|
#endif
|
|
|
|
void main(void)
|
|
{
|
|
float interp_time;
|
|
vec4 data0, data1, data2, data3;
|
|
hair_get_interp_attrs(data0, data1, data2, data3, interp_time);
|
|
|
|
vec4 weights = hair_get_weights_cardinal(interp_time);
|
|
finalColor = hair_interp_data(data0, data1, data2, data3, weights);
|
|
|
|
#ifdef TF_WORKAROUND
|
|
int id = gl_VertexID - idOffset;
|
|
gl_Position.x = ((float(id % targetWidth) + 0.5) / float(targetWidth)) * 2.0 - 1.0;
|
|
gl_Position.y = ((float(id / targetWidth) + 0.5) / float(targetHeight)) * 2.0 - 1.0;
|
|
gl_Position.z = 0.0;
|
|
gl_Position.w = 1.0;
|
|
|
|
gl_PointSize = 1.0;
|
|
#endif
|
|
}
|