示例#1
0
        internal void PSBindRawSRV(int slot, IShaderResourceBindable srv)
        {
            DeviceContext.PixelShader.SetShaderResources(0, srv.SRV);

            Stats.BindShaderResources++;
            MyRender11.ProcessDebugOutput();
        }
示例#2
0
        internal void PSBindRawSRV(int slot, IShaderResourceBindable srv)
        {
            ShaderResourceView sharpSRV = srv != null ? srv.SRV : null;

            DeviceContext.PixelShader.SetShaderResources(slot, sharpSRV);

            Stats.BindShaderResources++;
            MyRender11.ProcessDebugOutput();
        }
        static void AddSingleSprite(IShaderResourceBindable textureSrv, MyVertexFormatSpritePositionTextureRotationColor sprite)
        {
            if (StackTop().m_internalBatch.Texture != textureSrv && StackTop().m_internalBatch.Count > 0)
            {
                FlushInternalBatch();
            }
            StackTop().m_internalBatch.Texture = textureSrv;

            StackTop().m_internalBatch.AddSprite(sprite);
        }
        internal static void AddSingleSprite(IShaderResourceBindable view, Vector2 textureSize, Color color, Vector2 origin, Vector2 tangent, Rectangle?sourceRect, RectangleF destinationRect)
        {
            if (StackTop().m_internalBatch.ScissorRectangle.HasValue)
            {
                RectangleF intersection;
                var        scissor = StackTop().m_internalBatch.ScissorRectangle.Value;
                RectangleF.Intersect(ref scissor, ref destinationRect, out intersection);
                if (intersection.Size.X * intersection.Size.Y == 0)
                {
                    return;
                }
            }

            Vector2 clipOffset;

            Vector2 targetResolution = StackTop().m_resolution ?? MyRender11.ResolutionF;

            clipOffset   = destinationRect.Position / targetResolution * 2 - 1;
            clipOffset.Y = -clipOffset.Y;

            Vector2 texOffset = Vector2.Zero;
            Vector2 texScale  = Vector2.One;

            Vector2 originOffset;

            if (sourceRect != null)
            {
                Vector2 leftTop = new Vector2(sourceRect.Value.Left, sourceRect.Value.Top);
                Vector2 size    = new Vector2(sourceRect.Value.Width, sourceRect.Value.Height);
                texOffset = leftTop / textureSize;
                texScale  = size / textureSize;

                originOffset    = origin / new Vector2(sourceRect.Value.Width, sourceRect.Value.Height) - 0.5f;
                originOffset.Y *= -1;
            }
            else
            {
                originOffset    = origin / textureSize - 0.5f;
                originOffset.Y *= -1;
            }

            AddSingleSprite(view, new MyVertexFormatSpritePositionTextureRotationColor(
                                new HalfVector4(clipOffset.X, clipOffset.Y, destinationRect.Width, destinationRect.Height),
                                new HalfVector4(texOffset.X, texOffset.Y, texScale.X, texScale.Y),
                                new HalfVector4(originOffset.X, originOffset.Y, tangent.X, tangent.Y),
                                new Byte4(color.R, color.G, color.B, color.A)));
        }
示例#5
0
        internal static void AddSingleSprite(IShaderResourceBindable view, Vector2 textureSize, Color color, Vector2 origin, Vector2 tangent, Rectangle? sourceRect, RectangleF destinationRect)
        {
            if (StackTop().m_internalBatch.ScissorRectangle.HasValue)
            {
                RectangleF intersection;
                var scissor = StackTop().m_internalBatch.ScissorRectangle.Value;
                RectangleF.Intersect(ref scissor, ref destinationRect, out intersection);
                if (intersection.Size.X * intersection.Size.Y == 0)
                {
                    return;
                }
            }

            Vector2 clipOffset;

            Vector2 targetResolution = StackTop().m_resolution ?? MyRender11.ResolutionF;
            clipOffset = destinationRect.Position / targetResolution * 2 - 1;
            clipOffset.Y = -clipOffset.Y;

            Vector2 texOffset = Vector2.Zero;
            Vector2 texScale = Vector2.One;

            Vector2 originOffset;
            if (sourceRect != null)
            {
                Vector2 leftTop = new Vector2(sourceRect.Value.Left, sourceRect.Value.Top);
                Vector2 size = new Vector2(sourceRect.Value.Width, sourceRect.Value.Height);
                texOffset = leftTop / textureSize;
                texScale = size / textureSize;

                originOffset = origin / new Vector2(sourceRect.Value.Width, sourceRect.Value.Height) - 0.5f;
                originOffset.Y *= -1;
            }
            else
            {
                originOffset = origin / textureSize - 0.5f;
                originOffset.Y *= -1;
            }

            AddSingleSprite(view, new MyVertexFormatSpritePositionTextureRotationColor(
                new HalfVector4(clipOffset.X, clipOffset.Y, destinationRect.Width, destinationRect.Height),
                new HalfVector4(texOffset.X, texOffset.Y, texScale.X, texScale.Y),
                new HalfVector4(originOffset.X, originOffset.Y, tangent.X, tangent.Y),
                new Byte4(color.R, color.G, color.B, color.A)));
        }
示例#6
0
        static void AddSingleSprite(IShaderResourceBindable textureSrv, MyVertexFormatSpritePositionTextureRotationColor sprite)
        {
            if (StackTop().m_internalBatch.Texture != textureSrv && StackTop().m_internalBatch.Count > 0)
            {
                FlushInternalBatch();
            }
            StackTop().m_internalBatch.Texture = textureSrv;

            StackTop().m_internalBatch.AddSprite(sprite);
        }