Ejemplo n.º 1
0
        protected void CopyTo(BaseResource dest, SubresourceBox srcBox, uint srcSubresourceIndex, uint dstSubresourceIndex,
                              uint dstX, uint dstY, uint dstZ)
        {
            Assure.NotNull(dest);
            Assure.False(this == dest && srcSubresourceIndex == dstSubresourceIndex, "Can not copy to/from same subresource.");
            dest.ThrowIfCannotBeCopyDestination();

            lock (InstanceMutationLock) {
                if (IsDisposed)
                {
                    Logger.Warn("Attempted copy manipulation from disposed resource of type: " + GetType().Name);
                    return;
                }
                lock (dest.InstanceMutationLock) {
                    if (IsDisposed)
                    {
                        Logger.Warn("Attempted copy manipulation to disposed resource of type: " + GetType().Name);
                        return;
                    }
                    InteropUtils.CallNative(
                        NativeMethods.ResourceFactory_CopySubresourceRegion,
                        RenderingModule.DeviceContext,
                        ResourceHandle,
                        srcSubresourceIndex,
                        (IntPtr)(&srcBox),
                        dest.ResourceHandle,
                        dstSubresourceIndex,
                        dstX,
                        dstY,
                        dstZ
                        ).ThrowOnFailure();
                }
            }
        }
Ejemplo n.º 2
0
        protected void CopyTo(BaseResource dest)
        {
            Assure.NotNull(dest);
            Assure.NotEqual(this, dest, "Can not copy to self.");
            Assure.Equal(Size, dest.Size, "Resources must be of equal size.");
            Assure.Equal(GetType(), dest.GetType(), "Resources must be of equal type.");

            dest.ThrowIfCannotBeCopyDestination();

            lock (InstanceMutationLock) {
                if (IsDisposed)
                {
                    Logger.Warn("Attempted copy manipulation from disposed resource of type: " + GetType().Name);
                    return;
                }
                lock (dest.InstanceMutationLock) {
                    if (dest.IsDisposed)
                    {
                        Logger.Warn("Attempted copy manipulation to disposed resource of type: " + GetType().Name);
                        return;
                    }
                    InteropUtils.CallNative(
                        NativeMethods.ResourceFactory_CopyResource,
                        RenderingModule.DeviceContext,
                        ResourceHandle,
                        dest.ResourceHandle
                        ).ThrowOnFailure();
                }
            }
        }