public override int GetSourceSwizzle(int srcIndex)
        {
            D3D10OperandNumComponents componentSelection = GetOperandComponentSelection(srcIndex);

            if (componentSelection == D3D10OperandNumComponents.Operand1Component)
            {
                return((0 << 0) | (1 << 2) | (2 << 4) | (3 << 6));
            }
            else if (componentSelection == D3D10OperandNumComponents.Operand4Component)
            {
                D3D10ComponentSelectionMode selectionMode = GetOperandComponentSelectionMode(srcIndex);
                if (selectionMode == D3D10ComponentSelectionMode.Mask)
                {
                    return((0 << 0) | (1 << 2) | (2 << 4) | (3 << 6));
                }
                else if (selectionMode == D3D10ComponentSelectionMode.Swizzle)
                {
                    Span <uint> span = OperandTokens.GetSpan(srcIndex);
                    return((int)((span[0] >> 4) & 0xFF));
                }
                else if (selectionMode == D3D10ComponentSelectionMode.Select1)
                {
                    Span <uint> span      = OperandTokens.GetSpan(srcIndex);
                    int         component = (int)((span[0] >> 4) & 3);
                    return(component * 0x55);
                }
            }
            throw new NotImplementedException();
        }
        public override string GetDeclSemantic()
        {
            string name;

            switch (GetOperandType(0))
            {
            case OperandType.Input:
                name = "SV_Position";
                break;

            case OperandType.Output:
                name = "SV_Target";
                break;

            default:
                throw new NotImplementedException();
            }
            int declIndex = (int)OperandTokens.GetSpan(0)[1];

            if (declIndex != 0)
            {
                name += declIndex;
            }
            return(name);
        }
        private int GetOperandComponentSwizzle(int index, int component)
        {
            D3D10OperandNumComponents componentSelection = GetOperandComponentSelection(index);

            if (componentSelection == D3D10OperandNumComponents.Operand4Component)
            {
                D3D10ComponentSelectionMode selectionMode = GetOperandComponentSelectionMode(index);
                if (selectionMode == D3D10ComponentSelectionMode.Mask)
                {
                    Span <uint> span = OperandTokens.GetSpan(index);
                    int         mask = (int)((span[0] >> 4) & 0xF);
                    throw new NotImplementedException();
                    //return component;
                }
                else if (selectionMode == D3D10ComponentSelectionMode.Swizzle)
                {
                    Span <uint> span    = OperandTokens.GetSpan(index);
                    int         swizzle = (int)((span[0] >> 2) & 3);
                    return((swizzle >> (2 * component)) & 3);
                }
                else if (selectionMode == D3D10ComponentSelectionMode.Select1)
                {
                    throw new NotImplementedException();
                }
            }
            throw new NotImplementedException();
        }
        public D3D10OperandModifier GetOperandModifier(int index)
        {
            Span <uint> span = OperandTokens.GetSpan(index);

            if ((span[0] & 0x80000000f) == 0)
            {
                throw new InvalidOperationException();
            }
            return((D3D10OperandModifier)((span[1] >> 6) & 0xFF));
        }
        public override int GetParamRegisterNumber(int index)
        {
            Span <uint> span       = OperandTokens.GetSpan(index);
            bool        isExtended = (span[0] & 0x80000000) != 0;

            if (isExtended)
            {
                return((int)span[2]);
            }
            return((int)span[1]);
        }
        private byte[] GetOperandValueBytes(int index, int componentIndex)
        {
            Span <uint> span = OperandTokens.GetSpan(index);
            uint        value;

            if (Opcode == D3D10Opcode.DclTemps)
            {
                value = span[0];
            }
            else
            {
                var componentSelection = GetOperandComponentSelection(index);
                if (componentSelection == D3D10OperandNumComponents.Operand1Component)
                {
                    value = span[1];
                }
                else
                {
                    value = span[1 + componentIndex];
                }
            }
            return(BitConverter.GetBytes(value));
        }
        public override int GetDestinationWriteMask()
        {
            int destinationParamIndex = GetDestinationParamIndex();

            D3D10OperandNumComponents componentSelection = GetOperandComponentSelection(destinationParamIndex);

            if (componentSelection == D3D10OperandNumComponents.Operand4Component)
            {
                D3D10ComponentSelectionMode selectionMode = GetOperandComponentSelectionMode(destinationParamIndex);
                if (selectionMode == D3D10ComponentSelectionMode.Mask)
                {
                    Span <uint> span = OperandTokens.GetSpan(destinationParamIndex);
                    int         mask = (int)((span[0] >> 4) & 0xF);
                    return(mask);
                }
                else if (selectionMode == D3D10ComponentSelectionMode.Swizzle)
                {
                    int mask      = 0;
                    int dimension = GetOperandIndexDimension(destinationParamIndex);
                    for (int i = 0; i < dimension; i++)
                    {
                        int swizzle = GetOperandComponentSwizzle(destinationParamIndex, i);
                        if (swizzle != i)
                        {
                            mask |= 1 << swizzle;
                        }
                    }
                    return(mask);
                }
                else if (selectionMode == D3D10ComponentSelectionMode.Select1)
                {
                    throw new NotImplementedException();
                }
            }
            throw new NotImplementedException();
        }
        public OperandType GetOperandType(int index)
        {
            Span <uint> span = OperandTokens.GetSpan(index);

            return((OperandType)((span[0] >> 12) & 0xFF));
        }
        private D3D10ComponentSelectionMode GetOperandComponentSelectionMode(int index)
        {
            Span <uint> span = OperandTokens.GetSpan(index);

            return((D3D10ComponentSelectionMode)((span[0] >> 2) & 3));
        }
Пример #10
0
        public D3D10OperandNumComponents GetOperandComponentSelection(int index)
        {
            Span <uint> span = OperandTokens.GetSpan(index);

            return((D3D10OperandNumComponents)(span[0] & 3));
        }
Пример #11
0
        private int GetOperandIndexDimension(int index)
        {
            Span <uint> span = OperandTokens.GetSpan(index);

            return((int)((span[0] >> 20) & 3));
        }
Пример #12
0
        private D3D10InterpolationMode GetInterpolationMode()
        {
            Span <uint> span = OperandTokens.GetSpan(0);

            return((D3D10InterpolationMode)((span[0] >> 11) & 0xF));
        }