Skip to content

Commit

Permalink
[spline/bezier]Get rid of wasted if-checks at Graphics Processors.
Browse files Browse the repository at this point in the history
  • Loading branch information
xebra committed Oct 7, 2018
1 parent 41d6c3c commit 103d180
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions GPU/Directx9/VertexShaderGeneratorDX9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,11 +287,10 @@ void GenerateVertexShaderHLSL(const VShaderID &id, char *buffer, ShaderLanguage
// Define 3 types float2, float3, float4
WRITE(p, "float%d tess_sample(in float%d points[16], float4 weights_u, float4 weights_v) {\n", i, i);
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, " for (int u = 0; u < 4; ++u) {\n");
WRITE(p, " float f = weights_u[u] * weights_v[v];\n");
WRITE(p, " if (f != 0.0)\n");
WRITE(p, " pos = pos + f * points[v * 4 + u];\n");
WRITE(p, " pos += weights_u[u] * weights_v[v] * points[idx++];\n");
WRITE(p, " }\n");
WRITE(p, " }\n");
WRITE(p, " return pos;\n");
Expand Down
5 changes: 2 additions & 3 deletions GPU/GLES/VertexShaderGeneratorGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,10 @@ void GenerateVertexShader(const VShaderID &id, char *buffer, uint32_t *attrMask,
// Define 3 types vec2, vec3, vec4
WRITE(p, "vec%d tess_sample(in vec%d points[16], vec4 weights_u, vec4 weights_v) {\n", i, i);
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, " for (int u = 0; u < 4; ++u) {\n");
WRITE(p, " float f = weights_u[u] * weights_v[v];\n");
WRITE(p, " if (f != 0.0)\n");
WRITE(p, " pos += f * points[v * 4 + u];\n");
WRITE(p, " pos += weights_u[u] * weights_v[v] * points[idx++];\n");
WRITE(p, " }\n");
WRITE(p, " }\n");
WRITE(p, " return pos;\n");
Expand Down
5 changes: 2 additions & 3 deletions GPU/Vulkan/VertexShaderGeneratorVulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,10 @@ bool GenerateVulkanGLSLVertexShader(const VShaderID &id, char *buffer) {
// Define 3 types vec2, vec3, vec4
WRITE(p, "vec%d tess_sample(in vec%d points[16], vec4 weights_u, vec4 weights_v) {\n", i, i);
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, " for (int u = 0; u < 4; ++u) {\n");
WRITE(p, " float f = weights_u[u] * weights_v[v];\n");
WRITE(p, " if (f != 0.0)\n");
WRITE(p, " pos += f * points[v * 4 + u];\n");
WRITE(p, " pos += weights_u[u] * weights_v[v] * points[idx++];\n");
WRITE(p, " }\n");
WRITE(p, " }\n");
WRITE(p, " return pos;\n");
Expand Down

0 comments on commit 103d180

Please sign in to comment.