VirtualBox

Changeset 95168 in vbox


Ignore:
Timestamp:
Jun 2, 2022 5:46:52 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
151666
Message:

Devices/Graphics: stream output declarations. bugref:9830

File:
1 edited

Legend:

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

    r95151 r95168  
    13291329        pDst->SemanticName   = NULL; /* Semantic name and index will be taken from the shader output declaration. */
    13301330        pDst->SemanticIndex  = 0;
    1331         /* A geometry shader may return an attribute as a component:
    1332          *   Name   Index Mask Register
    1333          *   ATTRIB 3       z  2
    1334          * In this case SO declaration expects StartComponent = 0 and ComponentCount = 1
    1335          * (not StartComponent = 2 and ComponentCount = 1)
    1336          * This 'StartComponent = iFirstBit > 0 ? iFirstBit - 1 : 0;' did not work with a sample from a D3D11 book.
    1337          */
    1338         pDst->StartComponent = 0;
     1331        pDst->StartComponent = iFirstBit > 0 ? iFirstBit - 1 : 0;
    13391332        pDst->ComponentCount = iFirstBit > 0 ? iLastBit - (iFirstBit - 1) : 0;
    13401333        pDst->OutputSlot     = pSrc->outputSlot;
    13411334    }
    13421335
     1336    uint32_t MaxSemanticIndex = 0;
    13431337    for (uint32_t i = 0; i < pDXStreamOutput->cDeclarationEntry; ++i)
    13441338    {
     
    13641358            pDeclarationEntry->SemanticName = pOutputSemantic->pcszSemanticName;
    13651359            pDeclarationEntry->SemanticIndex = pOutputSemantic->SemanticIndex;
     1360            MaxSemanticIndex = RT_MAX(MaxSemanticIndex, pOutputSemantic->SemanticIndex);
    13661361        }
    13671362        else
    13681363            AssertFailed();
     1364    }
     1365
     1366    /* A geometry shader may return components of the same register as different attributes:
     1367     *
     1368     *   Output signature
     1369     *   Name           Index Mask        Register
     1370     *   ATTRIB         2     xy          2
     1371     *   ATTRIB         3       z         2
     1372     *
     1373     * For ATTRIB 3 the stream output declaration expects StartComponent = 0 and ComponentCount = 1
     1374     * (not StartComponent = 2 and ComponentCount = 1):
     1375     *
     1376     *   Stream output declaration
     1377     *   SemanticName   SemanticIndex StartComponent ComponentCount
     1378     *   ATTRIB         2             0              2
     1379     *   ATTRIB         3             0              1
     1380     *
     1381     * Stream output declaration can have multiple entries for the same attribute.
     1382     * In this case StartComponent is the offset within the attribute.
     1383     *
     1384     *   Output signature
     1385     *   Name           Index Mask        Register
     1386     *   ATTRIB         0     xyzw        0
     1387     *
     1388     *   Stream output declaration
     1389     *   SemanticName   SemanticIndex StartComponent ComponentCount
     1390     *   ATTRIB         0             0              1
     1391     *   ATTRIB         0             1              1
     1392     *
     1393     * StartComponent has been computed as the component offset in a register:
     1394     * 'StartComponent = iFirstBit > 0 ? iFirstBit - 1 : 0;'.
     1395     *
     1396     * StartComponent must be the offset in an attribute.
     1397     */
     1398    for (uint32_t SemanticIndex = 0; SemanticIndex <= MaxSemanticIndex; ++SemanticIndex)
     1399    {
     1400        /* Find minimum StartComponent value for this attribute. */
     1401        uint32_t MinStartComponent = UINT32_MAX;
     1402        for (uint32_t i = 0; i < pDXStreamOutput->cDeclarationEntry; ++i)
     1403        {
     1404            D3D11_SO_DECLARATION_ENTRY *pDeclarationEntry = &pDXStreamOutput->aDeclarationEntry[i];
     1405            if (pDeclarationEntry->SemanticIndex == SemanticIndex)
     1406                MinStartComponent = RT_MIN(MinStartComponent, pDeclarationEntry->StartComponent);
     1407        }
     1408
     1409        AssertContinue(MinStartComponent != UINT32_MAX);
     1410
     1411        /* Adjust the StartComponent to start from 0 for this attribute. */
     1412        for (uint32_t i = 0; i < pDXStreamOutput->cDeclarationEntry; ++i)
     1413        {
     1414            D3D11_SO_DECLARATION_ENTRY *pDeclarationEntry = &pDXStreamOutput->aDeclarationEntry[i];
     1415            if (pDeclarationEntry->SemanticIndex == SemanticIndex)
     1416                pDeclarationEntry->StartComponent -= MinStartComponent;
     1417        }
    13691418    }
    13701419
     
    56385687                    int rc = dxDefineStreamOutput(pThisCC, pDXContext, soid, pStreamOutputEntry, pDXShader);
    56395688                    AssertRCReturnVoid(rc);
     5689#ifdef LOG_ENABLED
     5690                    Log6(("Stream output declaration:\n\n"));
     5691                    Log6(("Stream SemanticName   SemanticIndex StartComponent ComponentCount OutputSlot\n"));
     5692                    Log6(("------ -------------- ------------- -------------- -------------- ----------\n"));
     5693                    for (unsigned i = 0; i < pDXStreamOutput->cDeclarationEntry; ++i)
     5694                    {
     5695                        D3D11_SO_DECLARATION_ENTRY *p = &pDXStreamOutput->aDeclarationEntry[i];
     5696                        Log6(("%d      %-14s %d             %d              %d              %d\n",
     5697                              p->Stream, p->SemanticName, p->SemanticIndex, p->StartComponent, p->ComponentCount, p->OutputSlot));
     5698                    }
     5699                    Log6(("\n"));
     5700#endif
     5701
    56405702                }
    56415703            }
Note: See TracChangeset for help on using the changeset viewer.

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