Exemplo n.º 1
0
        private static void ParseShader(D3D10EffectImplementation parent, D3D.Effect effect, D3D.EffectShaderVariable shaderVar)
        {
            D3D.EffectVariable testElem = shaderVar.GetElement(0);

            if (testElem == null)
            {
                if (shaderVar.IsValid)
                {
                    D3D.ShaderDescription shDesc;
                    shaderVar.GetShaderDescription(0, out shDesc);
                    D3DC.ShaderReflection reflect = new D3DC.ShaderReflection(shDesc.Bytecode);
                    ParseShaderParameters(parent, effect, reflect);

                    //Dispose of the reflection variable *and* the bytecode/signature of the shader desc...bytecode will reported as a leaked in ObjectTable
                    reflect.Dispose();
                    shDesc.Signature.Dispose();
                    shDesc.Bytecode.Dispose();
                }
            }
            else
            {
                int k = 1;
                while ((testElem = shaderVar.GetElement(k)) != null)
                {
                    if (testElem.IsValid)
                    {
                        D3D.ShaderDescription shDesc;
                        testElem.AsShader().GetShaderDescription(0, out shDesc);
                        D3DC.ShaderReflection reflect = new D3DC.ShaderReflection(shDesc.Bytecode);
                        ParseShaderParameters(parent, effect, reflect);

                        //Dispose of the reflection variable *and* the bytecode/signature of the shader desc...bytecode will reported as a leaked in ObjectTable
                        reflect.Dispose();
                        shDesc.Signature.Dispose();
                        shDesc.Bytecode.Dispose();
                    }
                    k++;
                }
            }
        }
Exemplo n.º 2
0
        private void CreateInputLayout(D3D.EffectShaderVariable shaderVar, int shaderIndex)
        {
            D3D.ShaderDescription shaderDesc;
            shaderVar.GetShaderDescription(shaderIndex, out shaderDesc);

            int paramCount = shaderDesc.InputParameterCount;

            //Dispose of the description's bytecode/sig...bytecode will be reported as a leak in ObjectTable
            shaderDesc.Bytecode.Dispose();
            shaderDesc.Signature.Dispose();

            VertexElement[] elements = new VertexElement[paramCount];
            D3D.ShaderParameterDescription desc;
            int offset = 0;

            for (int i = 0; i < paramCount; i++)
            {
                shaderVar.GetInputParameterDescription(shaderIndex, i, out desc);
                elements[i] = CreateVertexElement(desc, ref offset);
            }

            _layoutMap.CreateLayout(new VertexDeclaration(elements));
        }