This patch allows float3 integrator arrays to be declared using an explicit 12 byte packed type, if necessary. On Metal, we declare #define integrator_float3 packed_float3 since float3 is a padded 16 byte type in MSL.
Ref T92212
Differential D13236
Cycles: Integrator array float3 packing considerations for MSL Authored by Michael Jones (michael_jones) on Nov 16 2021, 12:59 PM. Tags None Subscribers None
Details
This patch allows float3 integrator arrays to be declared using an explicit 12 byte packed type, if necessary. On Metal, we declare #define integrator_float3 packed_float3 since float3 is a padded 16 byte type in MSL. Ref T92212
Diff Detail
Event TimelineComment Actions I'd prefer to have a packed_float3 defined for all devices, that implicitly casts to/from float3. It's not really specific to the integrator state, we also want to be able to use this in other data structures. Do you think D13243: Cycles: add packed_float3 type for storage instead of this would work for Metal? Comment Actions Yes, I prefer the explicitness of D13243: Cycles: add packed_float3 type for storage and think it paves the way for further optimisations :) The specific issue that this patch is addressing relates to these traits (specifically num_elements_gpu) which are wrong for Metal: template<> struct device_type_traits<float3> {
static const DataType data_type = TYPE_FLOAT;
static const size_t num_elements_cpu = 4;
static const size_t num_elements_gpu = 3;
static_assert(sizeof(float3) == num_elements_cpu * datatype_size(data_type));
}; |