Beispiel #1
0
        private string GetOperandDescription()
        {
            switch (OperandType)
            {
            case OperandType.UnorderedAccessView:
            case OperandType.Sampler:
            case OperandType.Resource:
                if (ParentType.IsDeclaration())
                {
                    if (IndexDimension == OperandIndexDimension._3D)
                    {
                        return(OperandType.GetDescription().ToUpper());
                    }
                    else
                    {
                        return(OperandType.GetDescription());
                    }
                }
                else
                {
                    if (IndexDimension == OperandIndexDimension._2D)
                    {
                        return(OperandType.GetDescription().ToUpper());
                    }
                    else
                    {
                        return(OperandType.GetDescription());
                    }
                }

            case OperandType.ConstantBuffer:
                if (IndexDimension == OperandIndexDimension._3D)
                {
                    return(OperandType.GetDescription().ToUpper());
                }
                else
                {
                    return(OperandType.GetDescription());
                }

            default:
                return(OperandType.GetDescription());
            }
        }
        public override string ToString()
        {
            string result = RegisterType.GetDescription();

            switch (RegisterType)
            {
            case OperandType.Input:
                result += Index.Index1D;
                break;

            case OperandType.Temp:
            case OperandType.Output:
            case OperandType.Sampler:
            case OperandType.Resource:
            case OperandType.UnorderedAccessView:
                result += Index.Index1D;
                break;

            case OperandType.ImmediateConstantBuffer:
            case OperandType.InputPatchConstant:
            case OperandType.ThreadGroupSharedMemory:
                result += string.Format("[{0}]", Index.Index1D);
                break;

            case OperandType.IndexableTemp:
            case OperandType.ConstantBuffer:
                result += string.Format("{0}[{1}]", Index.Index2D_0, Index.Index2D_1);
                break;

            case OperandType.InputGSInstanceID:
            case OperandType.InputControlPoint:
            case OperandType.OutputControlPoint:
                result += string.Format("[{0}][{1}]", Index.Index2D_0, Index.Index2D_1);
                break;
            }
            return(result);
        }
Beispiel #3
0
        public override string ToString()
        {
            switch (OperandType)
            {
            case OperandType.Immediate32:
            case OperandType.Immediate64:
            {
                string result    = (OperandType == OperandType.Immediate64) ? "d(" : "l(";
                bool   addSpaces = ParentType != OpcodeType.Mov && ParentType != OpcodeType.MovC && ParentType != OpcodeType.StoreStructured;
                for (int i = 0; i < NumComponents; i++)
                {
                    var parentType = ParentType.GetNumberType();
                    result += (OperandType == OperandType.Immediate64)
                                                                ? ImmediateValues.GetDouble(i).ToString()
                                                                : ImmediateValues.GetNumber(i).ToString(parentType);

                    if (i < NumComponents - 1)
                    {
                        result += ",";
                        if (addSpaces)
                        {
                            result += " ";
                        }
                    }
                }
                result += ")";
                return(result);
            }

            case OperandType.Null:
            {
                return(OperandType.GetDescription());
            }

            default:
            {
                string index = string.Empty;
                switch (IndexDimension)
                {
                case OperandIndexDimension._0D:
                    break;

                case OperandIndexDimension._1D:
                    index = (Indices[0].Representation == OperandIndexRepresentation.Relative ||
                             Indices[0].Representation == OperandIndexRepresentation.Immediate32PlusRelative ||
                             !OperandType.RequiresRegisterNumberFor1DIndex())
                                                                        ? string.Format("[{0}]", Indices[0])
                                                                        : Indices[0].ToString();
                    break;

                case OperandIndexDimension._2D:
                    index = (Indices[0].Representation == OperandIndexRepresentation.Relative ||
                             Indices[0].Representation == OperandIndexRepresentation.Immediate32PlusRelative ||
                             !OperandType.RequiresRegisterNumberFor2DIndex())
                                                                        ? string.Format("[{0}][{1}]", Indices[0], Indices[1])
                                                                        : string.Format("{0}[{1}]", Indices[0], Indices[1]);
                    break;

                case OperandIndexDimension._3D:
                    index = ParentType.IsDeclaration()
                                                                                ? string.Format("{0}[{1}:{2}]", Indices[0], Indices[1], Indices[2])
                                                                                : string.Format("{0}[{1}][{2}]", Indices[0], Indices[1], Indices[2]);
                    break;
                }

                string components = string.Empty;
                if (ParentType.OpcodeHasSwizzle())
                {
                    switch (SelectionMode)
                    {
                    case Operand4ComponentSelectionMode.Mask:
                        components = ComponentMask.GetDescription();
                        break;

                    case Operand4ComponentSelectionMode.Swizzle:
                        components = Swizzles[0].GetDescription()
                                     + Swizzles[1].GetDescription()
                                     + Swizzles[2].GetDescription()
                                     + Swizzles[3].GetDescription();
                        break;

                    case Operand4ComponentSelectionMode.Select1:
                        components = Swizzles[0].GetDescription();
                        break;

                    default:
                        throw new InvalidOperationException("Unrecognised selection mode: " + SelectionMode);
                    }
                    if (!string.IsNullOrEmpty(components))
                    {
                        components = "." + components;
                    }
                }
                string minPrecision = MinPrecision == OperandMinPrecision.Default ?
                                      string.Empty : $" {MinPrecision.GetDescription()}";
                return(Modifier.Wrap(string.Format("{0}{1}{2}{3}", GetOperandDescription(), index, components, minPrecision)));
            }
            }
        }
        ResourceBinding GetResourceBinding(OperandType type, uint id)
        {
            var resourceId = $"{type.GetDescription()}{id}";

            return(m_ResourceBindingLookup[resourceId]);
        }
        // TODO: Use OperandType for lookup instead of ShaderInputType
        ConstantBuffer GetConstantBuffer(OperandType type, uint id)
        {
            var resourceId = $"{type.GetDescription()}{id}";

            return(m_ConstantBufferLookup[resourceId]);
        }