Permalink
Browse files

[spline/bezier]Get rid of wasted if-checks at Graphics Processors.

  • Loading branch information...
xebra committed Jul 13, 2018
1 parent 41d6c3c commit 103d180ae7de18d1a8540451c29878aa4df0f39e
@@ -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");
@@ -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");
@@ -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");

0 comments on commit 103d180

Please sign in to comment.