Exemplo n.º 1
0
        static unsafe void Main(string[] args)
        {
            var shader = new TestShader();

            ShaderInterpreter <IVertexShader> .Interpret <TestShader>();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            ShaderInvoker <IVertexShader> .ChangeActiveShader(shader);

            Vector4[] input = new Vector4[itr_count];
            for (int i = 0; i < 480000 / itr_count; i++)
            {
                for (int j = 0; j < itr_count; j++)
                {
                    input[j].X = i;
                    input[j].Y = i;
                    input[j].Z = i;
                    input[j].W = i;
                }
                ShaderInvoker <IVertexShader> .Invoke(itr_count, input);
            }
            sw.Stop();
            WriteLine(sw.ElapsedMilliseconds);
            ReadKey();
        }
Exemplo n.º 2
0
        public unsafe void TestShaderInvoke()
        {
            TestShaderInterpret();
            var shader = new TestShader();

            ShaderInvoker <IVertexShader> .ChangeActiveShader(shader);

            ShaderInvoker <IFragmentShader> .ChangeActiveShader(shader);

            Vector4[] pos          = new Vector4[] { new Vector4(-1f, 2f, -3f, 4f) };
            Vector4   vertexResult = *ShaderInvoker <IVertexShader> .Invoke(0, pos).VertexPtr;

            Vector4 fragmentResult = *ShaderInvoker <IFragmentShader> .Invoke(0, pos).VertexPtr;

            Assert.AreEqual(vertexResult, new Vector4(-2.5f, 5f, -7.5f, 10f));
            Assert.AreEqual(fragmentResult, new Vector4(0f, 3f, -2f, 5f));
        }
Exemplo n.º 3
0
        public unsafe void TestShaderInvoke()
        {
            TestShaderInterpret();
            TestShader shader = new TestShader();

            ShaderInvoker <IVertexShader> .ChangeActiveShader(shader);

            ShaderInvoker <IFragmentShader> .ChangeActiveShader(shader);

            float *inputPtr = stackalloc float[4];

            Set(inputPtr, new Vector4(-1f, 2f, -3f, 4f));
            ShaderInvoker <IVertexShader> .Invoke(inputPtr);

            ShaderInvoker <IFragmentShader> .Invoke(inputPtr);

            Vector4 vertexResult   = *ShaderInvoker <IVertexShader> .InputLayoutPtr->VertexPtr;
            Vector4 fragmentResult = *ShaderInvoker <IFragmentShader> .OutputLayoutPtr->VertexPtr;

            Assert.AreEqual(vertexResult, new Vector4(-2.5f, 5f, -7.5f, 10f));
            Assert.AreEqual(fragmentResult, new Vector4(0f, 3f, -2f, 5f));
        }
Exemplo n.º 4
0
        static unsafe void Main(string[] args)
        {
            var shader = new TestShader();

            ShaderInterpreter <IVertexShader> .Interpret <TestShader>();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            ShaderInvoker <IVertexShader> .ChangeActiveShader(shader);

            float *zero = stackalloc float[4];

            *(Vector4 *)zero = Vector4.Zero;
            for (int i = 0; i < 480000; i++)
            {
                ShaderInvoker <IVertexShader> .Invoke(zero);
            }
            sw.Stop();
            WriteLine(sw.ElapsedMilliseconds);
            ReadKey();
        }