コード例 #1
0
ファイル: Texture.cs プロジェクト: aanntaa/Ryujinx
        /// <summary>
        /// Gets data from the host GPU.
        /// </summary>
        /// <remarks>
        /// This method should be used to retrieve data that was modified by the host GPU.
        /// This is not cheap, avoid doing that unless strictly needed.
        /// </remarks>
        /// <returns>Host texture data</returns>
        private Span <byte> GetTextureDataFromGpu(bool blacklist, ITexture texture = null)
        {
            Span <byte> data;

            if (texture != null)
            {
                data = texture.GetData();
            }
            else
            {
                if (blacklist)
                {
                    BlacklistScale();
                    data = HostTexture.GetData();
                }
                else if (ScaleFactor != 1f)
                {
                    float scale = ScaleFactor;
                    SetScale(1f);
                    data = HostTexture.GetData();
                    SetScale(scale);
                }
                else
                {
                    data = HostTexture.GetData();
                }
            }

            if (Info.IsLinear)
            {
                data = LayoutConverter.ConvertLinearToLinearStrided(
                    Info.Width,
                    Info.Height,
                    Info.FormatInfo.BlockWidth,
                    Info.FormatInfo.BlockHeight,
                    Info.Stride,
                    Info.FormatInfo.BytesPerPixel,
                    data);
            }
            else
            {
                data = LayoutConverter.ConvertLinearToBlockLinear(
                    Info.Width,
                    Info.Height,
                    _depth,
                    Info.Levels,
                    _layers,
                    Info.FormatInfo.BlockWidth,
                    Info.FormatInfo.BlockHeight,
                    Info.FormatInfo.BytesPerPixel,
                    Info.GobBlocksInY,
                    Info.GobBlocksInZ,
                    Info.GobBlocksInTileX,
                    _sizeInfo,
                    data);
            }

            return(data);
        }
コード例 #2
0
        public ReadOnlySpan <byte> GetData()
        {
            if (_renderer.IsGpuThread())
            {
                ResultBox <PinnedSpan <byte> > box = new ResultBox <PinnedSpan <byte> >();
                _renderer.New <TextureGetDataCommand>().Set(Ref(this), Ref(box));
                _renderer.InvokeCommand();

                return(box.Result.Get());
            }
            else
            {
                ThreadedHelpers.SpinUntilNonNull(ref Base);

                return(Base.GetData());
            }
        }
コード例 #3
0
 public void CreateBuffer()
 {
     if (data != null)
     {
         return;
     }
     if (texture == null)
     {
         data = new byte[4 * Size.Width * Size.Height];
     }
     else
     {
         data = texture.GetData();
     }
     releaseBufferOnCommit = false;
 }