Permalink
Browse files

[spline/bezier]Reduce multiplications in the shaders from 16 to 4.

  • Loading branch information...
xebra committed Jul 13, 2018
1 parent 103d180 commit de5975f13eb02a0be3adcd447fc973c312ec7ccc
@@ -289,8 +289,9 @@ void GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
WRITE(p, " float%d pos = float%d(%s);\n", i, i, init[i - 2]);
WRITE(p, " int idx = 0;\n");
WRITE(p, " for (int v = 0; v < 4; ++v) {\n");
WRITE(p, " float4 w = weights_u * weights_v[v];\n");
WRITE(p, " for (int u = 0; u < 4; ++u) {\n");
WRITE(p, " pos += weights_u[u] * weights_v[v] * points[idx++];\n");
WRITE(p, " pos += w[u] * points[idx++];\n");
WRITE(p, " }\n");
WRITE(p, " }\n");
WRITE(p, " return pos;\n");
@@ -392,8 +392,9 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
WRITE(p, " vec%d pos = vec%d(0.0);\n", i, i);
WRITE(p, " int idx = 0;\n");
WRITE(p, " for (int v = 0; v < 4; ++v) {\n");
WRITE(p, " vec4 w = weights_u * weights_v[v];\n");
WRITE(p, " for (int u = 0; u < 4; ++u) {\n");
WRITE(p, " pos += weights_u[u] * weights_v[v] * points[idx++];\n");
WRITE(p, " pos += w[u] * points[idx++];\n");
WRITE(p, " }\n");
WRITE(p, " }\n");
WRITE(p, " return pos;\n");
@@ -241,8 +241,9 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
WRITE(p, " vec%d pos = vec%d(0.0);\n", i, i);
WRITE(p, " int idx = 0;\n");
WRITE(p, " for (int v = 0; v < 4; ++v) {\n");
WRITE(p, " vec4 w = weights_u * weights_v[v];\n");
WRITE(p, " for (int u = 0; u < 4; ++u) {\n");
WRITE(p, " pos += weights_u[u] * weights_v[v] * points[idx++];\n");
WRITE(p, " pos += w[u] * points[idx++];\n");
WRITE(p, " }\n");
WRITE(p, " }\n");
WRITE(p, " return pos;\n");

0 comments on commit de5975f

Please sign in to comment.