VirtualBox

Changeset 90853 in vbox


Ignore:
Timestamp:
Aug 24, 2021 5:08:19 PM (3 years ago)
Author:
vboxsync
Message:

Devices/Graphics: support for relative operands in the shader parser.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-dx-shader.cpp

    r88803 r90853  
    104104{
    105105    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 */
    107108} VGPUOperandIndex;
    108109
     
    125126    uint32_t opcodeType;                /* VGPU10_OPCODE_* */
    126127    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. */
    129136} VGPUOpcode;
    130137
     
    12091216
    12101217/* Parse an instruction operand. */
    1211 static int dxbcParseOperand(DXBCTokenReader *r, VGPUOperand *pOperand)
    1212 {
    1213     RT_ZERO(*pOperand);
     1218static int dxbcParseOperand(DXBCTokenReader *r, VGPUOperand *paOperand, uint32_t *pcOperandRemain)
     1219{
     1220    ASSERT_GUEST_RETURN(*pcOperandRemain > 0, VERR_NOT_SUPPORTED);
    12141221
    12151222    ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 1), VERR_INVALID_PARAMETER);
     
    12761283        {
    12771284            ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 1), VERR_INVALID_PARAMETER);
    1278             pOperand->aImm[i] = dxbcTokenReaderRead32(r);
     1285            paOperand->aImm[i] = dxbcTokenReaderRead32(r);
    12791286        }
    12801287    }
    12811288
    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;
    12881296    /* 'indexDimension' tells the number of indices. 'i' is the array index, i.e. i = 0 for 1D, etc. */
    12891297    for (uint32_t i = 0; i < operand0.indexDimension; ++i)
    12901298    {
    12911299        if (i == 0)                                          /* VGPU10_OPERAND_INDEX_1D */
    1292             pOperand->aOperandIndex[i].indexRepresentation = operand0.index0Representation;
     1300            paOperand->aOperandIndex[i].indexRepresentation = operand0.index0Representation;
    12931301        else if (i == 1)                                     /* VGPU10_OPERAND_INDEX_2D */
    1294             pOperand->aOperandIndex[i].indexRepresentation = operand0.index1Representation;
     1302            paOperand->aOperandIndex[i].indexRepresentation = operand0.index1Representation;
    12951303        else                                                 /* VGPU10_OPERAND_INDEX_3D */
    12961304            continue; /* Skip because it is "rarely if ever used" and is not supported by VGPU10. */
    12971305
    1298         uint32_t const indexRepresentation = pOperand->aOperandIndex[i].indexRepresentation;
     1306        uint32_t const indexRepresentation = paOperand->aOperandIndex[i].indexRepresentation;
    12991307        switch (indexRepresentation)
    13001308        {
     
    13021310            {
    13031311                ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 1), VERR_INVALID_PARAMETER);
    1304                 pOperand->aOperandIndex[i].aOperandIndex[0] = dxbcTokenReaderRead32(r);
     1312                paOperand->aOperandIndex[i].iOperandImmediate = dxbcTokenReaderRead32(r);
    13051313                break;
    13061314            }
     
    13081316            {
    13091317                ASSERT_GUEST_RETURN(dxbcTokenReaderCanRead(r, 2), VERR_INVALID_PARAMETER);
    1310                 pOperand->aOperandIndex[i].aOperandIndex[0] = dxbcTokenReaderRead64(r);
     1318                paOperand->aOperandIndex[i].iOperandImmediate = dxbcTokenReaderRead64(r);
    13111319                break;
    13121320            }
     
    13141322            {
    13151323                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);
    13171327                break;
    13181328            }
     
    13201330            {
    13211331                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);
    13241336                break;
    13251337            }
     
    13271339            {
    13281340                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);
    13311345                break;
    13321346            }
     
    13341348                ASSERT_GUEST_FAILED_RETURN(VERR_INVALID_PARAMETER);
    13351349        }
    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;
    13391358    return VINF_SUCCESS;
    13401359}
     
    13571376    {
    13581377        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->aOperand), 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);
    13621381
    13631382        pOpcode->cOpcodeToken = opcode.instructionLength;
     
    13941413
    13951414        /* 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)
    13971417        {
    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);
    14001422            ASSERT_GUEST_RETURN(RT_SUCCESS(rc), VERR_INVALID_PARAMETER);
    14011423        }
     
    16041626            if (pSignatureEntry)
    16051627            {
    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;
    16071632                pSignatureEntry->semanticName  = opcode.semanticName;
    1608                 pSignatureEntry->mask          = opcode.aOperand[0].mask;
     1633                pSignatureEntry->mask          = opcode.aValOperand[0].mask;
    16091634                pSignatureEntry->componentType = SVGADX_SIGNATURE_REGISTER_COMPONENT_UNKNOWN; /// @todo Proper value? Seems that it is not important.
    16101635                pSignatureEntry->minPrecision  = SVGADX_SIGNATURE_MIN_PRECISION_DEFAULT;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette