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 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 Span <uint> GetSpan(int index) { int operandCount = 0; for (int i = 0; i < Tokens.Length;) { int spanStart = i; uint token = Tokens[i]; i++; D3D10OperandNumComponents componentSelection = (D3D10OperandNumComponents)(token & 3); bool isExtended = (token & 0x80000000) != 0; if (isExtended) { i++; } OperandType operandType = (OperandType)((token >> 12) & 0xFF); if (componentSelection == D3D10OperandNumComponents.Operand1Component) { if (operandType == OperandType.Immediate32) { i++; } } else if (componentSelection == D3D10OperandNumComponents.Operand4Component) { if (operandType == OperandType.Immediate32) { i += 4; } } int indexDimension = (int)((token >> 20) & 3); for (int r = 0; r < indexDimension; r++) { D3D10OperandIndexRepresentation indexRepresentation = (D3D10OperandIndexRepresentation)((token >> (22 + r * 3)) & 7); if (indexRepresentation == D3D10OperandIndexRepresentation.Immediate32) { i++; } else { throw new NotImplementedException(); } } if (operandCount == index) { return(new Span <uint>(Tokens, spanStart, i - spanStart)); } operandCount++; } return(new Span <uint>(Tokens, 0, 1)); }
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(); }