Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CopyData< T >() [1/3]

unsafe void Microsoft.Xna.Framework.Graphics.Texture3D.CopyData< T > ( int level,
int left,
int top,
int right,
int bottom,
int front,
int back,
T[] data,
int startIndex,
int elementCount,
uint options,
[MarshalAs(UnmanagedType.U1)] bool isSetting )
inlineprivate
Type Constraints
T :struct 

Definition at line 167 of file Texture3D.cs.

167 : struct
168 {
169 IntPtr intPtr = (IntPtr)pComPtr;
170 Helpers.CheckDisposed(this, intPtr);
171 if (data != null && data.Length != 0)
172 {
173 if (isSetting)
174 {
175 int num = 0;
176 GraphicsDevice parent = _parent;
177 if (0 < parent.Textures._maxTextures)
178 {
179 do
180 {
181 if (parent.Textures[num] != this)
182 {
183 num++;
184 parent = _parent;
185 continue;
186 }
187 throw GraphicsHelpers.GetExceptionFromResult(2147500036u);
188 }
189 while (num < parent.Textures._maxTextures);
190 }
191 int num2 = 0;
192 GraphicsDevice parent2 = _parent;
193 if (0 < parent2.VertexTextures._maxTextures)
194 {
195 do
196 {
197 if (parent2.VertexTextures[num2] != this)
198 {
199 num2++;
200 parent2 = _parent;
201 continue;
202 }
203 throw GraphicsHelpers.GetExceptionFromResult(2147500036u);
204 }
205 while (num2 < parent2.VertexTextures._maxTextures);
206 }
207 }
208 IDirect3DVolumeTexture9* ptr = pComPtr;
209 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DVOLUME_DESC d3DVOLUME_DESC);
210 int num3 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DVOLUME_DESC*, int>)(int)(*(uint*)(*(int*)ptr + 68)))((nint)ptr, (uint)level, &d3DVOLUME_DESC);
211 if (num3 < 0)
212 {
213 throw GraphicsHelpers.GetExceptionFromResult((uint)num3);
214 }
215 Helpers.ValidateCopyParameters(data.Length, startIndex, elementCount);
216 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DBOX d3DBOX);
217 *(int*)(&d3DBOX) = left;
218 System.Runtime.CompilerServices.Unsafe.As<_D3DBOX, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DBOX, 8)) = right;
219 System.Runtime.CompilerServices.Unsafe.As<_D3DBOX, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DBOX, 4)) = top;
220 System.Runtime.CompilerServices.Unsafe.As<_D3DBOX, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DBOX, 12)) = bottom;
221 System.Runtime.CompilerServices.Unsafe.As<_D3DBOX, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DBOX, 16)) = front;
222 System.Runtime.CompilerServices.Unsafe.As<_D3DBOX, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DBOX, 20)) = back;
223 System.Runtime.CompilerServices.Unsafe.SkipInit(out uint num4);
224 System.Runtime.CompilerServices.Unsafe.SkipInit(out uint num5);
225 GetAndValidateSizes<T>(&d3DVOLUME_DESC, &num4, &num5);
226 System.Runtime.CompilerServices.Unsafe.SkipInit(out uint num6);
227 System.Runtime.CompilerServices.Unsafe.SkipInit(out uint num7);
228 System.Runtime.CompilerServices.Unsafe.SkipInit(out uint num8);
229 GetAndValidateBox(&d3DVOLUME_DESC, &num6, &num7, &num8, &d3DBOX);
230 uint num9 = num6 * num7 * num8 * num4;
231 if ((int)num5 * elementCount != (int)num9)
232 {
233 throw new ArgumentException(FrameworkResources.InvalidTotalSize);
234 }
235 IDirect3DVolumeTexture9* ptr2 = pComPtr;
236 System.Runtime.CompilerServices.Unsafe.SkipInit(out _D3DLOCKED_BOX d3DLOCKED_BOX);
237 num3 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, _D3DLOCKED_BOX*, _D3DBOX*, uint, int>)(int)(*(uint*)(*(int*)ptr2 + 76)))((nint)ptr2, (uint)level, &d3DLOCKED_BOX, &d3DBOX, options);
238 if (num3 >= 0)
239 {
240 try
241 {
242 CopyData((void*)(int)System.Runtime.CompilerServices.Unsafe.As<_D3DLOCKED_BOX, uint>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DLOCKED_BOX, 8)), *(int*)(&d3DLOCKED_BOX), System.Runtime.CompilerServices.Unsafe.As<_D3DLOCKED_BOX, int>(ref System.Runtime.CompilerServices.Unsafe.AddByteOffset(ref d3DLOCKED_BOX, 4)), data, startIndex, elementCount, &d3DVOLUME_DESC, num6, num7, num8, isSetting);
243 }
244 finally
245 {
246 if (num3 >= 0)
247 {
248 ptr2 = pComPtr;
249 num3 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, uint, int>)(int)(*(uint*)(*(int*)ptr2 + 80)))((nint)ptr2, (uint)level);
250 }
251 }
252 if (num3 >= 0)
253 {
254 return;
255 }
256 }
257 throw GraphicsHelpers.GetExceptionFromResult((uint)num3);
258 }
259 throw new ArgumentNullException("data", FrameworkResources.NullNotAllowed);
260 }
unsafe IDirect3DVolumeTexture9 * pComPtr
Definition Texture3D.cs:18
static unsafe void GetAndValidateBox(_D3DVOLUME_DESC *pVolume, uint *pdwLockWidth, uint *pdwLockHeight, uint *pdwLockDepth, _D3DBOX *pBox)
Definition Texture3D.cs:345
static unsafe void GetAndValidateSizes< T >(_D3DVOLUME_DESC *pVolume, uint *pdwFormatSize, uint *pdwElementSize)
Definition Texture3D.cs:323

References Microsoft.Xna.Framework.Graphics.TextureCollection._maxTextures, Microsoft.Xna.Framework.Graphics.GraphicsResource._parent, Microsoft.Xna.Framework.Helpers.CheckDisposed(), Microsoft.Xna.Framework.Graphics.Texture3D.GetAndValidateBox(), Microsoft.Xna.Framework.Graphics.Texture3D.GetAndValidateSizes< T >(), Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.FrameworkResources.InvalidTotalSize, Microsoft.Xna.Framework.FrameworkResources.NullNotAllowed, System.options, Microsoft.Xna.Framework.Graphics.Texture3D.pComPtr, System.startIndex, Microsoft.Xna.Framework.Graphics.GraphicsDevice.Textures, Microsoft.Xna.Framework.Helpers.ValidateCopyParameters(), and Microsoft.Xna.Framework.Graphics.GraphicsDevice.VertexTextures.