Changeset 90853 in vbox
- Timestamp:
- Aug 24, 2021 5:08:19 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-shader.cpp
r88803 r90853 104 104 { 105 105 uint32_t indexRepresentation; /* VGPU10_OPERAND_INDEX_REPRESENTATION */ 106 uint64_t aOperandIndex[2]; /* Needs up to 2 qwords. */ 106 uint64_t iOperandImmediate; /* Needs up to a qword. */ 107 struct VGPUOperand *pOperandRelative; /* For VGPU10_OPERAND_INDEX_*RELATIVE */ 107 108 } VGPUOperandIndex; 108 109 … … 125 126 uint32_t opcodeType; /* VGPU10_OPCODE_* */ 126 127 uint32_t semanticName; /* SVGA3dDXSignatureSemanticName for system value declarations. */ 127 uint32_t cOperand; /* Nunber of operands. */ 128 VGPUOperand aOperand[8]; /* 8 should be enough for everyone. */ 128 uint32_t cOperand; /* Number of operands for this instruction. */ 129 uint32_t aIdxOperand[8]; /* Indices of the instruction operands in the aValOperand array. */ 130 /* 8 should be enough for everyone. */ 131 VGPUOperand aValOperand[16]; /* Operands including VGPU10_OPERAND_INDEX_*RELATIVE if they are used: */ 132 /* Operand1, VGPU10_OPERAND_INDEX_*RELATIVE for Operand1, ... */ 133 /* ... */ 134 /* OperandN, VGPU10_OPERAND_INDEX_*RELATIVE for OperandN, ... */ 135 /* 16 probably should be enough for everyone. */ 129 136 } VGPUOpcode; 130 137 … … 1209 1216 1210 1217 /* Parse an instruction operand. */ 1211 static int dxbcParseOperand(DXBCTokenReader *r, VGPUOperand *p Operand)1212 { 1213 RT_ZERO(*pOperand);1218 static int dxbcParseOperand(DXBCTokenReader *r, VGPUOperand *paOperand, uint32_t *pcOperandRemain) 1219 { 1220 ASSERT_GUEST_RETURN(*pcOperandRemain > 0, VERR_NOT_SUPPORTED); 1214 1221 1215 1222 ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 1), VERR_INVALID_PARAMETER); … … 1276 1283 { 1277 1284 ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 1), VERR_INVALID_PARAMETER); 1278 p Operand->aImm[i] = dxbcTokenReaderRead32(r);1285 paOperand->aImm[i] = dxbcTokenReaderRead32(r); 1279 1286 } 1280 1287 } 1281 1288 1282 pOperand->numComponents = operand0.numComponents; 1283 pOperand->selectionMode = operand0.selectionMode; 1284 pOperand->mask = operand0.mask; 1285 pOperand->operandType = operand0.operandType; 1286 pOperand->indexDimension = operand0.indexDimension; 1287 1289 paOperand->numComponents = operand0.numComponents; 1290 paOperand->selectionMode = operand0.selectionMode; 1291 paOperand->mask = operand0.mask; 1292 paOperand->operandType = operand0.operandType; 1293 paOperand->indexDimension = operand0.indexDimension; 1294 1295 int rc = VINF_SUCCESS; 1288 1296 /* 'indexDimension' tells the number of indices. 'i' is the array index, i.e. i = 0 for 1D, etc. */ 1289 1297 for (uint32_t i = 0; i < operand0.indexDimension; ++i) 1290 1298 { 1291 1299 if (i == 0) /* VGPU10_OPERAND_INDEX_1D */ 1292 p Operand->aOperandIndex[i].indexRepresentation = operand0.index0Representation;1300 paOperand->aOperandIndex[i].indexRepresentation = operand0.index0Representation; 1293 1301 else if (i == 1) /* VGPU10_OPERAND_INDEX_2D */ 1294 p Operand->aOperandIndex[i].indexRepresentation = operand0.index1Representation;1302 paOperand->aOperandIndex[i].indexRepresentation = operand0.index1Representation; 1295 1303 else /* VGPU10_OPERAND_INDEX_3D */ 1296 1304 continue; /* Skip because it is "rarely if ever used" and is not supported by VGPU10. */ 1297 1305 1298 uint32_t const indexRepresentation = p Operand->aOperandIndex[i].indexRepresentation;1306 uint32_t const indexRepresentation = paOperand->aOperandIndex[i].indexRepresentation; 1299 1307 switch (indexRepresentation) 1300 1308 { … … 1302 1310 { 1303 1311 ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 1), VERR_INVALID_PARAMETER); 1304 p Operand->aOperandIndex[i].aOperandIndex[0]= dxbcTokenReaderRead32(r);1312 paOperand->aOperandIndex[i].iOperandImmediate = dxbcTokenReaderRead32(r); 1305 1313 break; 1306 1314 } … … 1308 1316 { 1309 1317 ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 2), VERR_INVALID_PARAMETER); 1310 p Operand->aOperandIndex[i].aOperandIndex[0]= dxbcTokenReaderRead64(r);1318 paOperand->aOperandIndex[i].iOperandImmediate = dxbcTokenReaderRead64(r); 1311 1319 break; 1312 1320 } … … 1314 1322 { 1315 1323 ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 1), VERR_INVALID_PARAMETER); 1316 pOperand->aOperandIndex[i].aOperandIndex[0] = dxbcTokenReaderRead32(r); 1324 paOperand->aOperandIndex[i].pOperandRelative = &paOperand[1]; 1325 Log6((" [operand index %d] parsing relative\n", i)); 1326 rc = dxbcParseOperand(r, &paOperand[1], pcOperandRemain); 1317 1327 break; 1318 1328 } … … 1320 1330 { 1321 1331 ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 2), VERR_INVALID_PARAMETER); 1322 pOperand->aOperandIndex[i].aOperandIndex[0] = dxbcTokenReaderRead32(r); 1323 pOperand->aOperandIndex[i].aOperandIndex[1] = dxbcTokenReaderRead32(r); 1332 paOperand->aOperandIndex[i].iOperandImmediate = dxbcTokenReaderRead32(r); 1333 paOperand->aOperandIndex[i].pOperandRelative = &paOperand[1]; 1334 Log6((" [operand index %d] parsing relative\n", i)); 1335 rc = dxbcParseOperand(r, &paOperand[1], pcOperandRemain); 1324 1336 break; 1325 1337 } … … 1327 1339 { 1328 1340 ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 3), VERR_INVALID_PARAMETER); 1329 pOperand->aOperandIndex[i].aOperandIndex[0] = dxbcTokenReaderRead64(r); 1330 pOperand->aOperandIndex[i].aOperandIndex[1] = dxbcTokenReaderRead32(r); 1341 paOperand->aOperandIndex[i].iOperandImmediate = dxbcTokenReaderRead64(r); 1342 paOperand->aOperandIndex[i].pOperandRelative = &paOperand[1]; 1343 Log6((" [operand index %d] parsing relative\n", i)); 1344 rc = dxbcParseOperand(r, &paOperand[1], pcOperandRemain); 1331 1345 break; 1332 1346 } … … 1334 1348 ASSERT_GUEST_FAILED_RETURN(VERR_INVALID_PARAMETER); 1335 1349 } 1336 Log6((" [operand index %d] %s(%d): %#llx, %#llx\n", 1337 i, dxbcOperandIndexRepresentationToString(indexRepresentation), indexRepresentation, pOperand->aOperandIndex[i].aOperandIndex[0], pOperand->aOperandIndex[i].aOperandIndex[1])); 1338 } 1350 Log6((" [operand index %d] %s(%d): %#llx%s\n", 1351 i, dxbcOperandIndexRepresentationToString(indexRepresentation), indexRepresentation, 1352 paOperand->aOperandIndex[i].iOperandImmediate, paOperand->aOperandIndex[i].pOperandRelative ? " + relative" : "")); 1353 if (RT_FAILURE(rc)) 1354 break; 1355 } 1356 1357 *pcOperandRemain -= 1; 1339 1358 return VINF_SUCCESS; 1340 1359 } … … 1357 1376 { 1358 1377 Log6(("[%#x] %s length %d %s\n", 1359 dxbcTokenReaderByteOffset(r) , dxbcOpcodeToString(pOpcode->opcodeType), opcode.instructionLength, dxbcInterpolationModeToString(opcode.interpolationMode)));1360 1361 ASSERT_GUEST_RETURN(cOperand < RT_ELEMENTS(pOpcode->a Operand), VERR_INVALID_PARAMETER);1378 dxbcTokenReaderByteOffset(r) - 4, dxbcOpcodeToString(pOpcode->opcodeType), opcode.instructionLength, dxbcInterpolationModeToString(opcode.interpolationMode))); 1379 1380 ASSERT_GUEST_RETURN(cOperand < RT_ELEMENTS(pOpcode->aIdxOperand), VERR_INVALID_PARAMETER); 1362 1381 1363 1382 pOpcode->cOpcodeToken = opcode.instructionLength; … … 1394 1413 1395 1414 /* Operands. */ 1396 for (uint32_t iOperand = 0; iOperand < cOperand; ++iOperand) 1415 uint32_t cOperandRemain = RT_ELEMENTS(pOpcode->aValOperand); 1416 for (uint32_t i = 0; i < cOperand; ++i) 1397 1417 { 1398 Log6((" [operand %d]\n", iOperand)); 1399 int rc = dxbcParseOperand(r, &pOpcode->aOperand[iOperand]); 1418 Log6((" [operand %d]\n", i)); 1419 uint32_t const idxOperand = RT_ELEMENTS(pOpcode->aValOperand) - cOperandRemain; 1420 pOpcode->aIdxOperand[i] = idxOperand; 1421 int rc = dxbcParseOperand(r, &pOpcode->aValOperand[idxOperand], &cOperandRemain); 1400 1422 ASSERT_GUEST_RETURN(RT_SUCCESS(rc), VERR_INVALID_PARAMETER); 1401 1423 } … … 1604 1626 if (pSignatureEntry) 1605 1627 { 1606 pSignatureEntry->registerIndex = opcode.aOperand[0].aOperandIndex[0].aOperandIndex[0]; 1628 ASSERT_GUEST_RETURN( opcode.aValOperand[0].aOperandIndex[0].indexRepresentation == VGPU10_OPERAND_INDEX_IMMEDIATE32 1629 || opcode.aValOperand[0].aOperandIndex[0].indexRepresentation == VGPU10_OPERAND_INDEX_IMMEDIATE64, 1630 VERR_NOT_SUPPORTED); 1631 pSignatureEntry->registerIndex = opcode.aValOperand[0].aOperandIndex[0].iOperandImmediate; 1607 1632 pSignatureEntry->semanticName = opcode.semanticName; 1608 pSignatureEntry->mask = opcode.a Operand[0].mask;1633 pSignatureEntry->mask = opcode.aValOperand[0].mask; 1609 1634 pSignatureEntry->componentType = SVGADX_SIGNATURE_REGISTER_COMPONENT_UNKNOWN; /// @todo Proper value? Seems that it is not important. 1610 1635 pSignatureEntry->minPrecision = SVGADX_SIGNATURE_MIN_PRECISION_DEFAULT;
Note:
See TracChangeset
for help on using the changeset viewer.