public static RawShaderResourceViewDeclarationToken Parse(BytecodeReader reader)
        {
            var token0 = reader.ReadUInt32();

            return(new RawShaderResourceViewDeclarationToken
            {
                Operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10))
            });
        }
        public static RawThreadGroupSharedMemoryDeclarationToken Parse(BytecodeReader reader)
        {
            var token0 = reader.ReadUInt32();

            return(new RawThreadGroupSharedMemoryDeclarationToken
            {
                Operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10)),
                ElementCount = reader.ReadUInt32()
            });
        }
        public static ConstantBufferDeclarationToken Parse(BytecodeReader reader)
        {
            var token0 = reader.ReadUInt32();

            return(new ConstantBufferDeclarationToken
            {
                AccessPattern = token0.DecodeValue <ConstantBufferAccessPattern>(11, 11),
                Operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10))
            });
        }
        public static RawUnorderedAccessViewDeclarationToken Parse(BytecodeReader reader)
        {
            var token0 = reader.ReadUInt32();

            return(new RawUnorderedAccessViewDeclarationToken
            {
                Coherency = token0.DecodeValue <UnorderedAccessViewCoherency>(16, 16),
                Operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10))
            });
        }
Exemplo n.º 5
0
        public static StructuredThreadGroupSharedMemoryDeclarationToken Parse(BytecodeReader reader)
        {
            var token0 = reader.ReadUInt32();

            return(new StructuredThreadGroupSharedMemoryDeclarationToken
            {
                Operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10)),
                StructByteStride = reader.ReadUInt32(),
                StructCount = reader.ReadUInt32()
            });
        }
Exemplo n.º 6
0
        public static SamplerDeclarationToken Parse(BytecodeReader reader)
        {
            var token0  = reader.ReadUInt32();
            var operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10));

            return(new SamplerDeclarationToken
            {
                SamplerMode = token0.DecodeValue <SamplerMode>(11, 14),
                Operand = operand
            });
        }
Exemplo n.º 7
0
        public static StructuredUnorderedAccessViewDeclarationToken Parse(BytecodeReader reader)
        {
            var token0 = reader.ReadUInt32();

            return(new StructuredUnorderedAccessViewDeclarationToken
            {
                Coherency = token0.DecodeValue <UnorderedAccessViewCoherency>(16, 16),
                HasOrderPreservingCounter = (token0.DecodeValue(23, 23) == 0),
                Operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10)),
                ByteStride = reader.ReadUInt32()
            });
        }
        public static IndexingRangeDeclarationToken Parse(BytecodeReader reader)
        {
            var token0        = reader.ReadUInt32();
            var operand       = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10));
            var registerCount = reader.ReadUInt32();

            return(new IndexingRangeDeclarationToken
            {
                Operand = operand,
                RegisterCount = registerCount
            });
        }
Exemplo n.º 9
0
        public static TypedUnorderedAccessViewDeclarationToken Parse(BytecodeReader reader)
        {
            var token0 = reader.ReadUInt32();

            return(new TypedUnorderedAccessViewDeclarationToken
            {
                ResourceDimension = token0.DecodeValue <ResourceDimension>(11, 15),
                Coherency = token0.DecodeValue <UnorderedAccessViewCoherency>(16, 16),
                Operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10)),
                ReturnType = ResourceReturnTypeToken.Parse(reader)
            });
        }
Exemplo n.º 10
0
        public static RawShaderResourceViewDeclarationToken Parse(BytecodeReader reader, ShaderVersion version)
        {
            var token0 = reader.ReadUInt32();
            var result = new RawShaderResourceViewDeclarationToken
            {
                Operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10))
            };

            if (version.IsSM51)
            {
                result.SpaceIndex = reader.ReadUInt32();
            }
            return(result);
        }
Exemplo n.º 11
0
        public static ConstantBufferDeclarationToken Parse(BytecodeReader reader, ShaderVersion version)
        {
            var token0 = reader.ReadUInt32();
            var result = new ConstantBufferDeclarationToken
            {
                AccessPattern = token0.DecodeValue <ConstantBufferAccessPattern>(11, 11),
                Operand       = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10))
            };

            if (version.IsSM51)
            {
                result.m_ConstantBufferSize = reader.ReadUInt32();
                result.SpaceIndex           = reader.ReadUInt32();
            }
            return(result);
        }
Exemplo n.º 12
0
        public static SamplerDeclarationToken Parse(BytecodeReader reader, ShaderVersion version)
        {
            var token0  = reader.ReadUInt32();
            var operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10));
            var result  = new SamplerDeclarationToken
            {
                SamplerMode = token0.DecodeValue <SamplerMode>(11, 14),
                Operand     = operand
            };

            if (version.IsSM51)
            {
                result.SpaceIndex = reader.ReadUInt32();
            }
            return(result);
        }
        public static RawUnorderedAccessViewDeclarationToken Parse(BytecodeReader reader, ShaderVersion version)
        {
            var token0 = reader.ReadUInt32();
            var result = new RawUnorderedAccessViewDeclarationToken
            {
                Coherency             = token0.DecodeValue <UnorderedAccessViewCoherency>(16, 16),
                IsRasterOrderedAccess = token0.DecodeValue <bool>(17, 17),
                Operand = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10))
            };

            if (version.IsSM51)
            {
                result.SpaceIndex = reader.ReadUInt32();
            }
            return(result);
        }
        public static TypedUnorderedAccessViewDeclarationToken Parse(BytecodeReader reader, ShaderVersion version)
        {
            var token0 = reader.ReadUInt32();

            var result = new TypedUnorderedAccessViewDeclarationToken
            {
                ResourceDimension     = token0.DecodeValue <ResourceDimension>(11, 15),
                Coherency             = token0.DecodeValue <UnorderedAccessViewCoherency>(16, 16),
                IsRasterOrderedAccess = token0.DecodeValue <bool>(17, 17),
                Operand    = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10)),
                ReturnType = ResourceReturnTypeToken.Parse(reader)
            };

            if (version.IsSM51)
            {
                result.SpaceIndex = reader.ReadUInt32();
            }
            return(result);
        }
Exemplo n.º 15
0
        public static InputRegisterDeclarationToken Parse(BytecodeReader reader)
        {
            uint token0     = reader.ReadUInt32();
            var  opcodeType = token0.DecodeValue <OpcodeType>(0, 10);

            InputRegisterDeclarationToken result;

            switch (opcodeType)
            {
            case OpcodeType.DclInput:
            case OpcodeType.DclInputSgv:
            case OpcodeType.DclInputSiv:
                result = new InputRegisterDeclarationToken();
                break;

            case OpcodeType.DclInputPs:
            case OpcodeType.DclInputPsSgv:
            case OpcodeType.DclInputPsSiv:
                result = new PixelShaderInputRegisterDeclarationToken
                {
                    InterpolationMode = token0.DecodeValue <InterpolationMode>(11, 14)
                };
                break;

            default:
                throw new ParseException("Unrecognised opcode type: " + opcodeType);
            }

            result.Operand = Operand.Parse(reader, opcodeType);

            switch (opcodeType)
            {
            case OpcodeType.DclInputSgv:
            case OpcodeType.DclInputSiv:
            case OpcodeType.DclInputPsSgv:
            case OpcodeType.DclInputPsSiv:
                result.SystemValueName = NameToken.Parse(reader);
                break;
            }

            return(result);
        }
Exemplo n.º 16
0
        public static OutputRegisterDeclarationToken Parse(BytecodeReader reader)
        {
            uint token0     = reader.ReadUInt32();
            var  opcodeType = token0.DecodeValue <OpcodeType>(0, 10);

            var result = new OutputRegisterDeclarationToken
            {
                Operand = Operand.Parse(reader, opcodeType)
            };

            switch (opcodeType)
            {
            case OpcodeType.DclOutputSgv:
            case OpcodeType.DclOutputSiv:
                result.SystemValueName = NameToken.Parse(reader);
                break;
            }

            return(result);
        }
Exemplo n.º 17
0
        public static ResourceDeclarationToken Parse(BytecodeReader reader, ShaderVersion version)
        {
            var token0 = reader.ReadUInt32();

            var resourceDimension = token0.DecodeValue <ResourceDimension>(11, 15);

            byte sampleCount;

            switch (resourceDimension)
            {
            case ResourceDimension.Texture2DMultiSampled:
            case ResourceDimension.Texture2DMultiSampledArray:
                sampleCount = token0.DecodeValue <byte>(16, 22);
                break;

            default:
                sampleCount = 0;
                break;
            }

            var operand    = Operand.Parse(reader, token0.DecodeValue <OpcodeType>(0, 10));
            var returnType = ResourceReturnTypeToken.Parse(reader);
            var result     = new ResourceDeclarationToken
            {
                ResourceDimension = resourceDimension,
                SampleCount       = sampleCount,
                Operand           = operand,
                ReturnType        = returnType
            };

            if (version.IsSM51)
            {
                result.SpaceIndex = reader.ReadUInt32();
            }
            return(result);
        }
Exemplo n.º 18
0
        public static InstructionToken Parse(BytecodeReader reader, OpcodeHeader header)
        {
            var instructionToken = new InstructionToken();

            // Advance to next token.
            var instructionEnd = reader.CurrentPosition + (header.Length * sizeof(uint));
            var token0         = reader.ReadUInt32();

            if (header.OpcodeType == OpcodeType.Sync)
            {
                instructionToken.SyncFlags = token0.DecodeValue <SyncFlags>(11, 14);
            }
            else
            {
                instructionToken.ResInfoReturnType = token0.DecodeValue <ResInfoReturnType>(11, 12);
                instructionToken.Saturate          = (token0.DecodeValue(13, 13) == 1);
                instructionToken.TestBoolean       = token0.DecodeValue <InstructionTestBoolean>(18, 18);
                instructionToken.PreciseValueMask  = token0.DecodeValue <ComponentMask>(19, 22);
            }

            bool extended = header.IsExtended;

            while (extended)
            {
                uint extendedToken = reader.ReadUInt32();
                var  extendedType  = extendedToken.DecodeValue <InstructionTokenExtendedType>(0, 5);
                instructionToken.ExtendedTypes.Add(extendedType);
                extended = (extendedToken.DecodeValue(31, 31) == 1);

                switch (extendedType)
                {
                case InstructionTokenExtendedType.SampleControls:
                    instructionToken.SampleOffsets[0] = extendedToken.DecodeSigned4BitValue(09, 12);
                    instructionToken.SampleOffsets[1] = extendedToken.DecodeSigned4BitValue(13, 16);
                    instructionToken.SampleOffsets[2] = extendedToken.DecodeSigned4BitValue(17, 20);
                    break;

                case InstructionTokenExtendedType.ResourceDim:
                    instructionToken.ResourceTarget = extendedToken.DecodeValue <ResourceDimension>(6, 10);
                    instructionToken.ResourceStride = extendedToken.DecodeValue <ushort>(11, 22);
                    break;

                case InstructionTokenExtendedType.ResourceReturnType:
                    instructionToken.ResourceReturnTypes[0] = extendedToken.DecodeValue <ResourceReturnType>(06, 09);
                    instructionToken.ResourceReturnTypes[1] = extendedToken.DecodeValue <ResourceReturnType>(10, 13);
                    instructionToken.ResourceReturnTypes[2] = extendedToken.DecodeValue <ResourceReturnType>(14, 17);
                    instructionToken.ResourceReturnTypes[3] = extendedToken.DecodeValue <ResourceReturnType>(18, 21);
                    break;

                default:
                    throw new ParseException("Unrecognised extended type: " + extendedType);
                }
            }

            if (header.OpcodeType == OpcodeType.InterfaceCall)
            {
                // Interface call
                //
                // OpcodeToken0:
                //
                // [10:00] D3D10_SB_OPCODE_INTERFACE_CALL
                // [23:11] Ignored, 0
                // [30:24] Instruction length in DWORDs including the opcode token.
                // [31]    0 normally. 1 if extended operand definition, meaning next DWORD
                //         contains extended operand description.  If it is extended, then
                //         it contains the actual instruction length in DWORDs, since
                //         it may not fit into 7 bits if enough types are used.
                //
                // OpcodeToken0 is followed by a DWORD that gives the function index to
                // call in the function table specified for the given interface.
                // Next is the interface operand.
                instructionToken.FunctionIndex = reader.ReadUInt32();
            }

            while (reader.CurrentPosition < instructionEnd)
            {
                var operand = Operand.Parse(reader, header.OpcodeType);
                if (operand != null)
                {
                    instructionToken.Operands.Add(operand);
                }
            }
            return(instructionToken);
        }