Skip to content

Commit

Permalink
[spline/bezier]Reduce multiplications in the shaders from 16 to 4.
Browse files Browse the repository at this point in the history
  • Loading branch information
xebra committed Oct 7, 2018
1 parent 103d180 commit de5975f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion GPU/Directx9/VertexShaderGeneratorDX9.cpp
Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion GPU/GLES/VertexShaderGeneratorGLES.cpp
Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion GPU/Vulkan/VertexShaderGeneratorVulkan.cpp
Expand Up @@ -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");
Expand Down

0 comments on commit de5975f

Please sign in to comment.