protected ExecutableInstruction(InstructionToken instructionToken) { _instructionToken = instructionToken; }
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); }
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<byte>(11, 15); 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; }
public NonDivergentExecutableInstruction(InstructionToken instructionToken) : base(instructionToken) { }
public DivergentExecutableInstruction(InstructionToken instructionToken, bool branchIfPositive) : base(instructionToken) { _branchIfPositive = branchIfPositive; }