Feb 3, 2015 at 12:56 PM
Edited Feb 3, 2015 at 1:03 PM
I have my doubts about SetFloatVectorArray when offset is bigger than 0.
There is a line inside this method (EffectVariable.inl - line 2536)
std::min<size_t>((Offset + Count) * sizeof(CEffectVector4), pType->TotalSize));
For example if we have in hlsl float4 array and we want to fill second vector we will do this:
pVar->SetFloatVectorArray( someVals, 1, 1);
//we want to fill only second vector, thats why offset and count are 1
after that inside SetFloatVectorArray we will have memcpy like this:
memcpy(Data.pVector + 1, pData, 32); so we copy 32 bytes to last vector which is 16 bytes long and what is worse we copy it from 16 bytes buffer. So we write second 16 bytes over memory we don't own and from memory we don't own;
In my opinion this line in EffectVariable.inl should look like this:
memcpy(Data.pVector + Offset, pData, std::min<size_t>(Count * sizeof(CEffectVector4), pType->TotalSize-Offset * sizeof(CEffectVector4)));
Am I missing something, or no one were ever using offsets with this method?
Thanks in advance for any response.