mojoshader_common.c
changeset 1301 79bbc92200dc
parent 1300 f1cdc5187d53
child 1303 7a43f238f28a
equal deleted inserted replaced
1300:f1cdc5187d53 1301:79bbc92200dc
  1068     int pDataLen = pixel->output_len - sizeof(SpirvPatchTable);
  1068     int pDataLen = pixel->output_len - sizeof(SpirvPatchTable);
  1069     SpirvPatchTable *vTable = (SpirvPatchTable *) &vertex->output[vDataLen];
  1069     SpirvPatchTable *vTable = (SpirvPatchTable *) &vertex->output[vDataLen];
  1070     SpirvPatchTable *pTable = (SpirvPatchTable *) &pixel->output[pDataLen];
  1070     SpirvPatchTable *pTable = (SpirvPatchTable *) &pixel->output[pDataLen];
  1071     const uint32 texcoord0Loc = pTable->attrib_offsets[MOJOSHADER_USAGE_TEXCOORD][0];
  1071     const uint32 texcoord0Loc = pTable->attrib_offsets[MOJOSHADER_USAGE_TEXCOORD][0];
  1072 
  1072 
       
  1073     // We need locations for color outputs first!
       
  1074     for (i = 0; i < pixel->output_count; i ++)
       
  1075     {
       
  1076         const MOJOSHADER_attribute *pAttr = &pixel->outputs[i];
       
  1077         assert(pAttr->usage == MOJOSHADER_USAGE_COLOR);
       
  1078         if (pAttr->index == 0)
       
  1079             continue;
       
  1080 
       
  1081         pOffset = pTable->attrib_offsets[pAttr->usage][pAttr->index];
       
  1082         ((uint32 *) pixel->output)[pOffset] = attr_loc;
       
  1083         attr_loc++;
       
  1084     } // for
       
  1085 
       
  1086     // Okay, now we can start linking pixel/vertex attributes
  1073     for (i = 0; i < pixel->attribute_count; i++)
  1087     for (i = 0; i < pixel->attribute_count; i++)
  1074     {
  1088     {
  1075         const MOJOSHADER_attribute *pAttr = &pixel->attributes[i];
  1089         const MOJOSHADER_attribute *pAttr = &pixel->attributes[i];
  1076         if (pAttr->usage == MOJOSHADER_USAGE_UNKNOWN)
  1090         if (pAttr->usage == MOJOSHADER_USAGE_UNKNOWN)
  1077             continue; // Probably something like VPOS, ignore!
  1091             continue; // Probably something like VPOS, ignore!
  1102         if (!pTable->attrib_offsets[vAttr->usage][vAttr->index])
  1116         if (!pTable->attrib_offsets[vAttr->usage][vAttr->index])
  1103         {
  1117         {
  1104             vOffset = vTable->attrib_offsets[vAttr->usage][vAttr->index];
  1118             vOffset = vTable->attrib_offsets[vAttr->usage][vAttr->index];
  1105             ((uint32 *) vertex->output)[vOffset] = attr_loc++;
  1119             ((uint32 *) vertex->output)[vOffset] = attr_loc++;
  1106         } // if
  1120         } // if
  1107     } // while
  1121     } // for
  1108 
  1122 
  1109     // gl_PointCoord support
  1123     // gl_PointCoord support
  1110     if (texcoord0Loc)
  1124     if (texcoord0Loc)
  1111     {
  1125     {
  1112         if (vTable->attrib_offsets[MOJOSHADER_USAGE_POINTSIZE][0] > 0)
  1126         if (vTable->attrib_offsets[MOJOSHADER_USAGE_POINTSIZE][0] > 0)