RawTextureData is supposed to be the faster leaner version of making texture.
But here is what i’m getting when apply(false) is called:

then i commented out this line
![]()
and bam smooth and low

this is captured on the switch, deep profiler
so is this a bug in profiler? Raw being pretty bad? me calling apply wrong?
here is the script
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.VFX;
[DefaultExecutionOrder(-9999)]
public class VFXBatchController : MonoBehaviour
{
Texture2D _tex; // RGB for position, A for lifetime
static readonly int countID = Shader.PropertyToID("count");
static readonly int offsetID = Shader.PropertyToID("offset");
static readonly int positionsID = Shader.PropertyToID("positionslifetimes");
const int MAXCOUNT = 1000;
[Serializable]
public struct VFX
{
public int groupID;
public VisualEffect vfx;
}
public VFX[] vfx;
void OnEnable() { _tex = new Texture2D(MAXCOUNT, 1, GraphicsFormat.R32G32B32A32_SFloat, TextureCreationFlags.None); }
Vector4 _tmp = new Vector4();
void Update()
{
var positionsLifetimes = _tex.GetRawTextureData<Vector4>();
int offset = 0;
for (int vfxIndex = 0; vfxIndex < vfx.Length; vfxIndex++)
{
vfx[vfxIndex].vfx.SetInt(offsetID, offset);
var countEmitter = VFXBatchEmitter.emitters.ContainsKey(vfx[vfxIndex].groupID) ? VFXBatchEmitter.emitters[vfx[vfxIndex].groupID].Count : 0;
vfx[vfxIndex].vfx.SetInt(countID, countEmitter);
if (countEmitter == 0)
continue;
var emitters = VFXBatchEmitter.emitters[vfx[vfxIndex].groupID];
for (var emitterIndex = 0; emitterIndex < countEmitter; emitterIndex++)
{
var emitter = emitters[emitterIndex];
if (emitter.lifetime > 0)
{
var tp = emitter.transform.position;
_tmp.Set(tp.x, tp.y, tp.z, emitter.lifetime);
positionsLifetimes[offset + emitterIndex] = _tmp;
}
}
offset += countEmitter;
}
_tex.Apply(false);
for (int i = 0; i < vfx.Length; i++)
{
vfx[i].vfx.SetTexture(positionsID, _tex);
}
}
}
