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_global const KernelGlobals *kg, | ccl_device AttributeDescriptor svm_node_attr_init(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| uint4 node, | uint4 node, | ||||
| ccl_private NodeAttributeOutputType *type, | ccl_private NodeAttributeOutputType *type, | ||||
| ccl_private uint *out_offset) | ccl_private uint *out_offset) | ||||
| { | { | ||||
| *out_offset = node.z; | *out_offset = node.z; | ||||
| *type = (NodeAttributeOutputType)node.w; | *type = (NodeAttributeOutputType)node.w; | ||||
| Show All 13 Lines | else { | ||||
| desc.offset = 0; | desc.offset = 0; | ||||
| desc.type = (NodeAttributeType)node.w; | desc.type = (NodeAttributeType)node.w; | ||||
| } | } | ||||
| return desc; | return desc; | ||||
| } | } | ||||
| template<uint node_feature_mask> | template<uint node_feature_mask> | ||||
| ccl_device_noinline void svm_node_attr(ccl_global const KernelGlobals *kg, | ccl_device_noinline void svm_node_attr(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint4 node) | 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)) { | 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); | ||||
| ▲ Show 20 Lines • Show All 73 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_noinline void svm_node_attr_bump_dx(ccl_global const KernelGlobals *kg, | ccl_device_noinline void svm_node_attr_bump_dx(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint4 node) | 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); | ||||
| ▲ Show 20 Lines • Show All 79 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_noinline void svm_node_attr_bump_dy(ccl_global const KernelGlobals *kg, | ccl_device_noinline void svm_node_attr_bump_dy(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private float *stack, | ccl_private float *stack, | ||||
| uint4 node) | 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); | ||||
| ▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines | |||||