[Bf-blender-cvs] [a450f8a7ae1] cycles-x: Fix Cycles X AOV writing not working
Brecht Van Lommel
noreply at git.blender.org
Tue Jun 8 19:51:09 CEST 2021
Commit: a450f8a7ae18bd601c906213802118de61367b22
Author: Brecht Van Lommel
Date: Tue Jun 8 19:10:13 2021 +0200
Branches: cycles-x
https://developer.blender.org/rBa450f8a7ae18bd601c906213802118de61367b22
Fix Cycles X AOV writing not working
===================================================================
M intern/cycles/kernel/integrator/integrator_state.h
M intern/cycles/kernel/svm/svm.h
M intern/cycles/kernel/svm/svm_aov.h
===================================================================
diff --git a/intern/cycles/kernel/integrator/integrator_state.h b/intern/cycles/kernel/integrator/integrator_state.h
index 1dda6b67c23..a28df75959a 100644
--- a/intern/cycles/kernel/integrator/integrator_state.h
+++ b/intern/cycles/kernel/integrator/integrator_state.h
@@ -143,7 +143,7 @@ typedef struct IntegratorStateGPU {
# define INTEGRATOR_STATE_PASS kg, state
# define INTEGRATOR_STATE_PASS_NULL kg, NULL
-# define INTEGRATOR_STATE_IS_NULL state == NULL
+# define INTEGRATOR_STATE_IS_NULL (state == NULL)
# define INTEGRATOR_STATE(nested_struct, member) \
(((const IntegratorState *)state)->nested_struct.member)
diff --git a/intern/cycles/kernel/svm/svm.h b/intern/cycles/kernel/svm/svm.h
index ea394abe599..aa77d3d44ba 100644
--- a/intern/cycles/kernel/svm/svm.h
+++ b/intern/cycles/kernel/svm/svm.h
@@ -220,7 +220,7 @@ CCL_NAMESPACE_BEGIN
template<uint node_feature_mask, ShaderType type>
ccl_device void svm_eval_nodes(INTEGRATOR_STATE_CONST_ARGS,
ShaderData *sd,
- ccl_global float *buffer,
+ ccl_global float *render_buffer,
int path_flag)
{
float stack[SVM_STACK_SIZE];
@@ -567,15 +567,15 @@ ccl_device void svm_eval_nodes(INTEGRATOR_STATE_CONST_ARGS,
}
break;
case NODE_AOV_START:
- if (!svm_node_aov_check(path_flag, buffer)) {
+ if (!svm_node_aov_check(path_flag, render_buffer)) {
return;
}
break;
case NODE_AOV_COLOR:
- svm_node_aov_color(kg, sd, stack, node, buffer);
+ svm_node_aov_color(INTEGRATOR_STATE_PASS, sd, stack, node, render_buffer);
break;
case NODE_AOV_VALUE:
- svm_node_aov_value(kg, sd, stack, node, buffer);
+ svm_node_aov_value(INTEGRATOR_STATE_PASS, sd, stack, node, render_buffer);
break;
#endif /* NODES_GROUP(NODE_GROUP_LEVEL_4) */
default:
diff --git a/intern/cycles/kernel/svm/svm_aov.h b/intern/cycles/kernel/svm/svm_aov.h
index cd5edc68607..403df254bd9 100644
--- a/intern/cycles/kernel/svm/svm_aov.h
+++ b/intern/cycles/kernel/svm/svm_aov.h
@@ -18,30 +18,45 @@
CCL_NAMESPACE_BEGIN
-ccl_device_inline bool svm_node_aov_check(const int path_flag, ccl_global float *buffer)
+ccl_device_inline bool svm_node_aov_check(const int path_flag, ccl_global float *render_buffer)
{
bool is_primary = (path_flag & PATH_RAY_CAMERA) && (!(path_flag & PATH_RAY_SINGLE_PASS_DONE));
- return ((buffer != NULL) && is_primary);
+ return ((render_buffer != NULL) && is_primary);
}
-ccl_device void svm_node_aov_color(
- const KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ccl_global float *buffer)
+ccl_device void svm_node_aov_color(INTEGRATOR_STATE_CONST_ARGS,
+ ShaderData *sd,
+ float *stack,
+ uint4 node,
+ ccl_global float *render_buffer)
{
float3 val = stack_load_float3(stack, node.y);
- if (buffer) {
- kernel_write_pass_float4(buffer + kernel_data.film.pass_aov_color + 4 * node.z,
- make_float4(val.x, val.y, val.z, 1.0f));
+ if (render_buffer && !INTEGRATOR_STATE_IS_NULL) {
+ const uint32_t render_pixel_index = INTEGRATOR_STATE(path, render_pixel_index);
+ const uint64_t render_buffer_offset = (uint64_t)render_pixel_index *
+ kernel_data.film.pass_stride;
+ ccl_global float *buffer = render_buffer + render_buffer_offset +
+ (kernel_data.film.pass_aov_color + 4 * node.z);
+ kernel_write_pass_float4(buffer, make_float4(val.x, val.y, val.z, 1.0f));
}
}
-ccl_device void svm_node_aov_value(
- const KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node, ccl_global float *buffer)
+ccl_device void svm_node_aov_value(INTEGRATOR_STATE_CONST_ARGS,
+ ShaderData *sd,
+ float *stack,
+ uint4 node,
+ ccl_global float *render_buffer)
{
float val = stack_load_float(stack, node.y);
- if (buffer) {
+ if (render_buffer && !INTEGRATOR_STATE_IS_NULL) {
+ const uint32_t render_pixel_index = INTEGRATOR_STATE(path, render_pixel_index);
+ const uint64_t render_buffer_offset = (uint64_t)render_pixel_index *
+ kernel_data.film.pass_stride;
+ ccl_global float *buffer = render_buffer + render_buffer_offset +
+ (kernel_data.film.pass_aov_value + node.z);
kernel_write_pass_float(buffer + kernel_data.film.pass_aov_value + node.z, val);
}
}
More information about the Bf-blender-cvs
mailing list