Пример #1
0
        public void UpdateImage(DX11RenderContext context, DX11Resource <DX11DynamicTexture2D> texture, byte[] data)
        {
            if (FInvalidate || !texture.Contains(context))
            {
                var fmt = SlimDX.DXGI.Format.R8_UNorm;

                if (texture.Contains(context))
                {
                    var imgdesc = texture[context].Resource.Description;

                    if (imgdesc.Width != ValidImage.Width || imgdesc.Height != ValidImage.Height || imgdesc.Format != fmt)
                    {
                        texture.Dispose(context);
                        texture[context] = new DX11DynamicTexture2D(context, ValidImage.Width, ValidImage.Height, fmt);
                    }
                }
                else
                {
                    texture[context] = new DX11DynamicTexture2D(context, ValidImage.Width, ValidImage.Height, fmt);
#if DEBUG
                    texture[context].Resource.DebugName = "DynamicTexture";
#endif
                }
                texture[context].WriteData(data);
            }
        }
Пример #2
0
        public void UpdateDistMap(DX11RenderContext context, DX11Resource <DX11DynamicTexture2D> texture, Image.CameraType side)
        {
            if (FInvalidate || !texture.Contains(context))
            {
                var fmt = SlimDX.DXGI.Format.R32G32_Float;

                if (texture.Contains(context))
                {
                    var imgdesc = texture[context].Resource.Description;

                    if (imgdesc.Width != ValidImage.DistortionWidth / 2 || imgdesc.Height != ValidImage.DistortionHeight || imgdesc.Format != fmt)
                    {
                        texture.Dispose(context);
                        texture[context] = new DX11DynamicTexture2D(context, ValidImage.DistortionWidth / 2, ValidImage.DistortionHeight, fmt);
                    }
                }
                else
                {
                    texture[context] = new DX11DynamicTexture2D(context, ValidImage.DistortionWidth / 2, ValidImage.DistortionHeight, fmt);
#if DEBUG
                    texture[context].Resource.DebugName = "DynamicTexture";
#endif
                }

                texture[context].WriteData(ValidImage.Distortion(side), 2);
            }
        }
Пример #3
0
 private static void CheckBufferDispose <T>(DX11RenderContext context, DX11Resource <IDX11ReadableStructureBuffer> bufferResource, int bufferCount, bool bufferTypeChanged)
     where T : struct
 {
     if (bufferResource.Contains(context))
     {
         if (bufferResource[context].ElementCount < bufferCount ||
             bufferTypeChanged ||
             bufferResource[context] is DX11ImmutableStructuredBuffer <T> )
         {
             bufferResource.Dispose(context);
         }
     }
 }