FNA icon indicating copy to clipboard operation
FNA copied to clipboard

Add Texture2D.GetDataPointerEXT

Open kg opened this issue 1 year ago • 3 comments

Without this, it's not possible to cleanly queue up texture readback operations to execute later, since GetData<T> checks the size of T against the texture format, instead of checking the size of the buffer - so you can't read a Color texture into a byte[] even if it's big enough.

kg avatar Apr 13 '24 22:04 kg

I might be misremembering but I thought this worked like SetData where byte[] was okay... are we just missing some math checks that exist in SetData?

flibitijibibo avatar Apr 13 '24 22:04 flibitijibibo

I might be misremembering but I thought this worked like SetData where byte[] was okay... are we just missing some math checks that exist in SetData?

The

	int elementSizeInBytes = MarshalHelper.SizeOf<T>();
	ValidateGetDataFormat(Format, elementSizeInBytes);

should reject an attempt to download a Color surface into a byte[], I think. IIRC the last time I tried it, it didn't work.

kg avatar Apr 13 '24 22:04 kg

Alternate proposal: Don't do this, instead we add GetDataPointerAsyncEXT/SetDataPointerAsyncEXT, which only work on the SDL_GPU backend. If we had those I'd use them instead

kg avatar Aug 30 '24 20:08 kg