unsafe JobHandle?GetColors32Job( void *input, GLTFComponentType inputType, GLTFAccessorAttributeType attributeType, int inputByteStride, NativeArray <float4> output ) { Profiler.BeginSample("PrepareColors32"); JobHandle?jobHandle = null; if (attributeType == GLTFAccessorAttributeType.VEC3) { switch (inputType) { case GLTFComponentType.UnsignedByte: { var job = new Jobs.ConvertColorsRGBUInt8ToRGBAFloatJob { input = (byte *)input, inputByteStride = inputByteStride > 0 ? inputByteStride : 3, result = output }; jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); } break; case GLTFComponentType.Float: { var job = new Jobs.ConvertColorsRGBFloatToRGBAFloatJob { input = (byte *)input, inputByteStride = inputByteStride > 0 ? inputByteStride : 12, result = (float4 *)output.GetUnsafePtr() }; jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); } break; case GLTFComponentType.UnsignedShort: { var job = new Jobs.ConvertColorsRGBUInt16ToRGBAFloatJob { input = (System.UInt16 *)input, inputByteStride = inputByteStride > 0 ? inputByteStride : 6, result = output }; jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); } break; default: logger?.Error(LogCode.ColorFormatUnsupported, attributeType.ToString()); break; } } else if (attributeType == GLTFAccessorAttributeType.VEC4) { switch (inputType) { case GLTFComponentType.UnsignedByte: { var job = new Jobs.ConvertColorsRGBAUInt8ToRGBAFloatJob { input = (byte *)input, inputByteStride = inputByteStride > 0 ? inputByteStride : 4, result = output }; jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); } break; case GLTFComponentType.Float: { if (inputByteStride == 16 || inputByteStride <= 0) { var job = new Jobs.MemCopyJob { bufferSize = output.Length * 16, input = input, result = output.GetUnsafeReadOnlyPtr() }; jobHandle = job.Schedule(); } else { var job = new Jobs.ConvertColorsRGBAFloatToRGBAFloatJob { input = (byte *)input, inputByteStride = inputByteStride, result = (float4 *)output.GetUnsafePtr() }; #if UNITY_JOBS jobHandle = job.ScheduleBatch(output.Length, GltfImport.DefaultBatchCount); #else jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); #endif } } break; case GLTFComponentType.UnsignedShort: { var job = new Jobs.ConvertColorsRGBAUInt16ToRGBAFloatJob { input = (System.UInt16 *)input, inputByteStride = inputByteStride > 0 ? inputByteStride : 8, result = (float4 *)output.GetUnsafePtr() }; #if UNITY_JOBS jobHandle = job.ScheduleBatch(output.Length, GltfImport.DefaultBatchCount); #else jobHandle = job.Schedule(output.Length, GltfImport.DefaultBatchCount); #endif } break; default: logger?.Error(LogCode.ColorFormatUnsupported, attributeType.ToString()); break; } } else { logger?.Error(LogCode.TypeUnsupported, "color accessor", inputType.ToString()); } Profiler.EndSample(); return(jobHandle); }
unsafe JobHandle?GetColors32Job( void *input, GLTFComponentType inputType, GLTFAccessorAttributeType attributeType, int inputByteStride, NativeArray <Color> output ) { Profiler.BeginSample("PrepareColors32"); JobHandle?jobHandle = null; if (attributeType == GLTFAccessorAttributeType.VEC3) { switch (inputType) { case GLTFComponentType.UnsignedByte: { var job = new Jobs.GetColorsVec3UInt8Job { input = (byte *)input, inputByteStride = inputByteStride > 0 ? inputByteStride : 3, result = output }; jobHandle = job.Schedule(output.Length, GLTFast.DefaultBatchCount); } break; case GLTFComponentType.Float: { var job = new Jobs.GetColorsVec3FloatJob { input = (float *)input, inputByteStride = inputByteStride > 0 ? inputByteStride : 12, result = output }; jobHandle = job.Schedule(output.Length, GLTFast.DefaultBatchCount); } break; case GLTFComponentType.UnsignedShort: { var job = new Jobs.GetColorsVec3UInt16Job { input = (System.UInt16 *)input, inputByteStride = inputByteStride > 0 ? inputByteStride : 6, result = output }; jobHandle = job.Schedule(output.Length, GLTFast.DefaultBatchCount); } break; default: Debug.LogErrorFormat(GLTFast.ErrorUnsupportedColorFormat, attributeType); break; } } else if (attributeType == GLTFAccessorAttributeType.VEC4) { switch (inputType) { case GLTFComponentType.UnsignedByte: { var job = new Jobs.GetColorsVec4UInt8Job { input = (byte *)input, inputByteStride = inputByteStride > 0 ? inputByteStride : 4, result = output }; jobHandle = job.Schedule(output.Length, GLTFast.DefaultBatchCount); } break; case GLTFComponentType.Float: { var job = new Jobs.MemCopyJob(); job.bufferSize = output.Length * 16; job.input = input; job.result = NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr(output); jobHandle = job.Schedule(); } break; case GLTFComponentType.UnsignedShort: { var job = new Jobs.GetColorsVec4UInt16Job { input = (System.UInt16 *)input, inputByteStride = inputByteStride > 0 ? inputByteStride : 8, result = output }; jobHandle = job.Schedule(output.Length, GLTFast.DefaultBatchCount); } break; default: Debug.LogErrorFormat(GLTFast.ErrorUnsupportedColorFormat, attributeType); break; } } else { Debug.LogErrorFormat(GLTFast.ErrorUnsupportedType, "color accessor", inputType); } Profiler.EndSample(); return(jobHandle); }