me-main #1

Merged
Nate Rupsis merged 123 commits from me-main into main 2023-02-13 18:39:11 +01:00
2 changed files with 17 additions and 1 deletions
Showing only changes of commit 77963ff778 - Show all commits

View File

@ -149,7 +149,7 @@ static void gpu_node_input_link(GPUNode *node, GPUNodeLink *link, const eGPUType
case GPU_NODE_LINK_DIFFERENTIATE_FLOAT_FN: case GPU_NODE_LINK_DIFFERENTIATE_FLOAT_FN:
input->source = GPU_SOURCE_FUNCTION_CALL; input->source = GPU_SOURCE_FUNCTION_CALL;
/* NOTE(@fclem): End of function call is the return variable set during codegen. */ /* NOTE(@fclem): End of function call is the return variable set during codegen. */
SNPRINTF(input->function_call, "dF_branch(%s(), ", link->function_name); SNPRINTF(input->function_call, "dF_branch_incomplete(%s(), ", link->function_name);
break; break;
default: default:
break; break;

View File

@ -228,6 +228,11 @@ void dF_branch(float fn, out vec2 result)
result = vec2(0.0); result = vec2(0.0);
} }
void dF_branch_incomplete(float fn, out vec2 result)
{
result = vec2(0.0);
}
#elif 0 /* TODO(@fclem): User Option? */ #elif 0 /* TODO(@fclem): User Option? */
/* Fast derivatives */ /* Fast derivatives */
vec3 dF_impl(vec3 v) vec3 dF_impl(vec3 v)
@ -257,6 +262,17 @@ vec3 dF_impl(vec3 v)
} }
# define dF_branch(fn, result) \ # define dF_branch(fn, result) \
if (true) { \
g_derivative_flag = 1; \
result.x = (fn); \
g_derivative_flag = -1; \
result.y = (fn); \
g_derivative_flag = 0; \
result -= vec2((fn)); \
}
/* Used when the non-offset value is already computed elsewhere */
# define dF_branch_incomplete(fn, result) \
if (true) { \ if (true) { \
g_derivative_flag = 1; \ g_derivative_flag = 1; \
result.x = (fn); \ result.x = (fn); \