Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/svm/svm_attribute.h
| Show All 12 Lines | |||||
| * See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | ||||
| * limitations under the License. | * limitations under the License. | ||||
| */ | */ | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Attribute Node */ | /* Attribute Node */ | ||||
| ccl_device AttributeDescriptor svm_node_attr_init( | ccl_device AttributeDescriptor svm_node_attr_init(const KernelGlobals *kg, | ||||
| KernelGlobals *kg, ShaderData *sd, uint4 node, NodeAttributeOutputType *type, uint *out_offset) | ShaderData *sd, | ||||
| uint4 node, | |||||
| NodeAttributeOutputType *type, | |||||
| uint *out_offset) | |||||
| { | { | ||||
| *out_offset = node.z; | *out_offset = node.z; | ||||
| *type = (NodeAttributeOutputType)node.w; | *type = (NodeAttributeOutputType)node.w; | ||||
| AttributeDescriptor desc; | AttributeDescriptor desc; | ||||
| if (sd->object != OBJECT_NONE) { | if (sd->object != OBJECT_NONE) { | ||||
| desc = find_attribute(kg, sd, node.y); | desc = find_attribute(kg, sd, node.y); | ||||
| if (desc.offset == ATTR_STD_NOT_FOUND) { | if (desc.offset == ATTR_STD_NOT_FOUND) { | ||||
| desc = attribute_not_found(); | desc = attribute_not_found(); | ||||
| desc.offset = 0; | desc.offset = 0; | ||||
| desc.type = (NodeAttributeType)node.w; | desc.type = (NodeAttributeType)node.w; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* background */ | /* background */ | ||||
| desc = attribute_not_found(); | desc = attribute_not_found(); | ||||
| desc.offset = 0; | desc.offset = 0; | ||||
| desc.type = (NodeAttributeType)node.w; | desc.type = (NodeAttributeType)node.w; | ||||
| } | } | ||||
| return desc; | return desc; | ||||
| } | } | ||||
| ccl_device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) | template<uint node_feature_mask> | ||||
| ccl_device_noinline void svm_node_attr(const KernelGlobals *kg, | |||||
| ShaderData *sd, | |||||
| float *stack, | |||||
| uint4 node) | |||||
| { | { | ||||
| NodeAttributeOutputType type = NODE_ATTR_OUTPUT_FLOAT; | NodeAttributeOutputType type = NODE_ATTR_OUTPUT_FLOAT; | ||||
| uint out_offset = 0; | uint out_offset = 0; | ||||
| AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | ||||
| #ifdef __VOLUME__ | #ifdef __VOLUME__ | ||||
| if (KERNEL_NODES_FEATURE(VOLUME)) { | |||||
| /* Volumes | /* Volumes | ||||
| * NOTE: moving this into its own node type might help improve performance. */ | * NOTE: moving this into its own node type might help improve performance. */ | ||||
| if (primitive_is_volume_attribute(sd, desc)) { | if (primitive_is_volume_attribute(sd, desc)) { | ||||
| const float4 value = volume_attribute_float4(kg, sd, desc); | const float4 value = volume_attribute_float4(kg, sd, desc); | ||||
| if (type == NODE_ATTR_OUTPUT_FLOAT) { | if (type == NODE_ATTR_OUTPUT_FLOAT) { | ||||
| const float f = volume_attribute_value_to_float(value); | const float f = volume_attribute_value_to_float(value); | ||||
| stack_store_float(stack, out_offset, f); | stack_store_float(stack, out_offset, f); | ||||
| } | } | ||||
| else if (type == NODE_ATTR_OUTPUT_FLOAT3) { | else if (type == NODE_ATTR_OUTPUT_FLOAT3) { | ||||
| const float3 f = volume_attribute_value_to_float3(value); | const float3 f = volume_attribute_value_to_float3(value); | ||||
| stack_store_float3(stack, out_offset, f); | stack_store_float3(stack, out_offset, f); | ||||
| } | } | ||||
| else { | else { | ||||
| const float f = volume_attribute_value_to_alpha(value); | const float f = volume_attribute_value_to_alpha(value); | ||||
| stack_store_float(stack, out_offset, f); | stack_store_float(stack, out_offset, f); | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| } | |||||
| #endif | #endif | ||||
| if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) { | if (node.y == ATTR_STD_GENERATED && desc.element == ATTR_ELEMENT_NONE) { | ||||
| /* No generated attribute, fall back to object coordinates. */ | /* No generated attribute, fall back to object coordinates. */ | ||||
| float3 f = sd->P; | float3 f = sd->P; | ||||
| object_inverse_position_transform(kg, sd, &f); | object_inverse_position_transform(kg, sd, &f); | ||||
| if (type == NODE_ATTR_OUTPUT_FLOAT) { | if (type == NODE_ATTR_OUTPUT_FLOAT) { | ||||
| stack_store_float(stack, out_offset, average(f)); | stack_store_float(stack, out_offset, average(f)); | ||||
| ▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | else if (type == NODE_ATTR_OUTPUT_FLOAT3) { | ||||
| stack_store_float3(stack, out_offset, f); | stack_store_float3(stack, out_offset, f); | ||||
| } | } | ||||
| else { | else { | ||||
| stack_store_float(stack, out_offset, 1.0f); | stack_store_float(stack, out_offset, 1.0f); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ccl_device void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) | ccl_device_noinline void svm_node_attr_bump_dx(const KernelGlobals *kg, | ||||
| ShaderData *sd, | |||||
| float *stack, | |||||
| uint4 node) | |||||
| { | { | ||||
| NodeAttributeOutputType type = NODE_ATTR_OUTPUT_FLOAT; | NodeAttributeOutputType type = NODE_ATTR_OUTPUT_FLOAT; | ||||
| uint out_offset = 0; | uint out_offset = 0; | ||||
| AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | ||||
| #ifdef __VOLUME__ | #ifdef __VOLUME__ | ||||
| /* Volume */ | /* Volume */ | ||||
| if (primitive_is_volume_attribute(sd, desc)) { | if (primitive_is_volume_attribute(sd, desc)) { | ||||
| ▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Lines | else if (type == NODE_ATTR_OUTPUT_FLOAT3) { | ||||
| stack_store_float3(stack, out_offset, f + dx); | stack_store_float3(stack, out_offset, f + dx); | ||||
| } | } | ||||
| else { | else { | ||||
| stack_store_float(stack, out_offset, 1.0f); | stack_store_float(stack, out_offset, 1.0f); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ccl_device void svm_node_attr_bump_dy(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) | ccl_device_noinline void svm_node_attr_bump_dy(const KernelGlobals *kg, | ||||
| ShaderData *sd, | |||||
| float *stack, | |||||
| uint4 node) | |||||
| { | { | ||||
| NodeAttributeOutputType type = NODE_ATTR_OUTPUT_FLOAT; | NodeAttributeOutputType type = NODE_ATTR_OUTPUT_FLOAT; | ||||
| uint out_offset = 0; | uint out_offset = 0; | ||||
| AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | ||||
| #ifdef __VOLUME__ | #ifdef __VOLUME__ | ||||
| /* Volume */ | /* Volume */ | ||||
| if (primitive_is_volume_attribute(sd, desc)) { | if (primitive_is_volume_attribute(sd, desc)) { | ||||
| ▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines | |||||