private void TranslatePostfixAttributes(ShaderTranslationContext sc, IEnumerable <Attribute> attributes, char?registerName, int fieldIndex, int fieldSize, MappedConstantBuffer cBuffer) { foreach (Attribute a in attributes) { switch (a) { case RegisterAttribute regAtt: if (registerName == null) { continue; } int slotID = (int)(regAtt.Slot + fieldIndex); cBuffer?.BindSlots.Add(new BindPointInfo(regAtt.Model, regAtt.ApplicableEntryPoint, slotID)); if (regAtt.ApplicableEntryPoint == EntryPointType.AnyOrNone) { sc.Source.Append($" : register({registerName}{slotID})"); } else { string profile = regAtt.Model.ToString().Replace("SM", _profileNames[regAtt.ApplicableEntryPoint]); sc.Source.Append($" : register({profile}, {registerName}{slotID})"); } break; case PackOffsetAttribute packAtt: if (cBuffer == null) { continue; } int totalComponentOffset = (packAtt.OffsetRegister * COMPONENTS_PER_REGISTER) + (int)packAtt.OffsetComponent; totalComponentOffset += (int)Math.Floor((fieldSize * fieldIndex) / (float)COMPONENT_BYTE_SIZE); PackOffsetComponent component = (PackOffsetComponent)(totalComponentOffset % COMPONENTS_PER_REGISTER); int register = (int)Math.Floor(totalComponentOffset / (float)COMPONENTS_PER_REGISTER); string componentName = component.ToString().ToLower(); sc.Source.Append($" : packoffset(c{register}.{componentName})"); break; case SemanticAttribute semAtt: if (cBuffer != null) { continue; } string semanticName = semAtt.Semantic.ToString().ToUpper(); sc.Source.Append($" : {semanticName}"); if (semAtt.Slot >= 0) { sc.Source.Append(semAtt.Slot.ToString()); } break; } } }
public PackOffsetAttribute(int offsetRegister, PackOffsetComponent offsetComponent = PackOffsetComponent.X) { OffsetRegister = offsetRegister; OffsetComponent = offsetComponent; }