VirtualBox

Changeset 102617 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Dec 15, 2023 5:25:47 PM (14 months ago)
Author:
vboxsync
Message:

Devices/Graphics: shader signature semantics.

File:
1 edited

Legend:

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

    r99688 r102617  
    20802080
    20812081static void dxbcGenerateSemantics(DXShaderInfo *pInfo, uint32_t cSignature,
    2082                                   SVGA3dDXSignatureEntry const *paSignature,
     2082                                  SVGA3dDXSignatureEntry *paSignature,
    20832083                                  DXShaderAttributeSemantic *paSemantic,
    20842084                                  uint32_t u32BlobType);
     
    24182418    { "SV_IsFrontFace",                 1 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_IS_FRONT_FACE                      9
    24192419    { "SV_SampleIndex",                 1 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_SAMPLE_INDEX                       10
    2420     /** @todo  Is this a correct name for all TessFactors? */
    24212420    { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_U_EQ_0_EDGE_TESSFACTOR  11
    24222421    { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_V_EQ_0_EDGE_TESSFACTOR  12
    24232422    { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_U_EQ_1_EDGE_TESSFACTOR  13
    24242423    { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_V_EQ_1_EDGE_TESSFACTOR  14
    2425     { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_U_INSIDE_TESSFACTOR     15
    2426     { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_V_INSIDE_TESSFACTOR     16
     2424    { "SV_InsideTessFactor",            3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_U_INSIDE_TESSFACTOR     15
     2425    { "SV_InsideTessFactor",            3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_V_INSIDE_TESSFACTOR     16
    24272426    { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_TRI_U_EQ_0_EDGE_TESSFACTOR   17
    24282427    { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_TRI_V_EQ_0_EDGE_TESSFACTOR   18
    24292428    { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_TRI_W_EQ_0_EDGE_TESSFACTOR   19
    2430     { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_TRI_INSIDE_TESSFACTOR        20
     2429    { "SV_InsideTessFactor",            3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_TRI_INSIDE_TESSFACTOR        20
    24312430    { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_LINE_DETAIL_TESSFACTOR       21
    24322431    { "SV_TessFactor",                  3 }, // SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_LINE_DENSITY_TESSFACTOR      22
     
    24362435    { "SV_TARGET",                      3 }; // SVGADX_SIGNATURE_SEMANTIC_NAME_UNDEFINED                          0
    24372436
     2437
     2438/* A clone of D3D_NAME */
     2439typedef enum
     2440{
     2441    D3D_SV_UNDEFINED = 0,
     2442    D3D_SV_POSITION = 1,
     2443    D3D_SV_CLIP_DISTANCE = 2,
     2444    D3D_SV_CULL_DISTANCE = 3,
     2445    D3D_SV_RENDER_TARGET_ARRAY_INDEX = 4,
     2446    D3D_SV_VIEWPORT_ARRAY_INDEX = 5,
     2447    D3D_SV_VERTEX_ID = 6,
     2448    D3D_SV_PRIMITIVE_ID = 7,
     2449    D3D_SV_INSTANCE_ID = 8,
     2450    D3D_SV_IS_FRONT_FACE = 9,
     2451    D3D_SV_SAMPLE_INDEX = 10,
     2452    D3D_SV_FINAL_QUAD_EDGE_TESSFACTOR = 11,
     2453    D3D_SV_FINAL_QUAD_INSIDE_TESSFACTOR = 12,
     2454    D3D_SV_FINAL_TRI_EDGE_TESSFACTOR = 13,
     2455    D3D_SV_FINAL_TRI_INSIDE_TESSFACTOR = 14,
     2456    D3D_SV_FINAL_LINE_DETAIL_TESSFACTOR = 15,
     2457    D3D_SV_FINAL_LINE_DENSITY_TESSFACTOR = 16
     2458} D3DSYSTEMVALUE;
     2459
     2460static uint32_t svga2dxSystemValue(SVGA3dDXSignatureSemanticName semanticName)
     2461{
     2462    switch (semanticName)
     2463    {
     2464        case SVGADX_SIGNATURE_SEMANTIC_NAME_UNDEFINED:                 return D3D_SV_UNDEFINED;
     2465        case SVGADX_SIGNATURE_SEMANTIC_NAME_POSITION:                  return D3D_SV_POSITION;
     2466        case SVGADX_SIGNATURE_SEMANTIC_NAME_CLIP_DISTANCE:             return D3D_SV_CLIP_DISTANCE;
     2467        case SVGADX_SIGNATURE_SEMANTIC_NAME_CULL_DISTANCE:             return D3D_SV_CULL_DISTANCE;
     2468        case SVGADX_SIGNATURE_SEMANTIC_NAME_RENDER_TARGET_ARRAY_INDEX: return D3D_SV_RENDER_TARGET_ARRAY_INDEX;
     2469        case SVGADX_SIGNATURE_SEMANTIC_NAME_VIEWPORT_ARRAY_INDEX:      return D3D_SV_VIEWPORT_ARRAY_INDEX;
     2470        case SVGADX_SIGNATURE_SEMANTIC_NAME_VERTEX_ID:                 return D3D_SV_VERTEX_ID;
     2471        case SVGADX_SIGNATURE_SEMANTIC_NAME_PRIMITIVE_ID:              return D3D_SV_PRIMITIVE_ID;
     2472        case SVGADX_SIGNATURE_SEMANTIC_NAME_INSTANCE_ID:               return D3D_SV_INSTANCE_ID;
     2473        case SVGADX_SIGNATURE_SEMANTIC_NAME_IS_FRONT_FACE:             return D3D_SV_IS_FRONT_FACE;
     2474        case SVGADX_SIGNATURE_SEMANTIC_NAME_SAMPLE_INDEX:              return D3D_SV_SAMPLE_INDEX;
     2475        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_U_EQ_0_EDGE_TESSFACTOR: return D3D_SV_FINAL_QUAD_EDGE_TESSFACTOR;
     2476        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_V_EQ_0_EDGE_TESSFACTOR: return D3D_SV_FINAL_QUAD_EDGE_TESSFACTOR;
     2477        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_U_EQ_1_EDGE_TESSFACTOR: return D3D_SV_FINAL_QUAD_EDGE_TESSFACTOR;
     2478        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_V_EQ_1_EDGE_TESSFACTOR: return D3D_SV_FINAL_QUAD_EDGE_TESSFACTOR;
     2479        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_U_INSIDE_TESSFACTOR:    return D3D_SV_FINAL_QUAD_INSIDE_TESSFACTOR;
     2480        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_QUAD_V_INSIDE_TESSFACTOR:    return D3D_SV_FINAL_QUAD_INSIDE_TESSFACTOR;
     2481        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_TRI_U_EQ_0_EDGE_TESSFACTOR:  return D3D_SV_FINAL_TRI_EDGE_TESSFACTOR;
     2482        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_TRI_V_EQ_0_EDGE_TESSFACTOR:  return D3D_SV_FINAL_TRI_EDGE_TESSFACTOR;
     2483        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_TRI_W_EQ_0_EDGE_TESSFACTOR:  return D3D_SV_FINAL_TRI_EDGE_TESSFACTOR;
     2484        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_TRI_INSIDE_TESSFACTOR:       return D3D_SV_FINAL_TRI_INSIDE_TESSFACTOR;
     2485        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_LINE_DETAIL_TESSFACTOR:      return D3D_SV_FINAL_LINE_DETAIL_TESSFACTOR;
     2486        case SVGADX_SIGNATURE_SEMANTIC_NAME_FINAL_LINE_DENSITY_TESSFACTOR:     return D3D_SV_FINAL_LINE_DENSITY_TESSFACTOR;
     2487    }
     2488
     2489    AssertFailedReturn(D3D_SV_UNDEFINED);
     2490}
    24382491
    24392492static VGPUSemanticInfo const *dxbcSemanticInfo(DXShaderInfo const *pInfo, SVGA3dDXSignatureSemanticName enmSemanticName, uint32_t u32BlobType)
     
    24522505
    24532506static void dxbcGenerateSemantics(DXShaderInfo *pInfo, uint32_t cSignature,
    2454                                   SVGA3dDXSignatureEntry const *paSignature,
     2507                                  SVGA3dDXSignatureEntry *paSignature,
    24552508                                  DXShaderAttributeSemantic *paSemantic,
    24562509                                  uint32_t u32BlobType)
     
    24582511    for (uint32_t iSignatureEntry = 0; iSignatureEntry < cSignature; ++iSignatureEntry)
    24592512    {
    2460         SVGA3dDXSignatureEntry const *src = &paSignature[iSignatureEntry];
    2461         DXShaderAttributeSemantic *dst = &paSemantic[iSignatureEntry];
    2462 
    2463         ASSERT_GUEST_RETURN_VOID(src->semanticName < SVGADX_SIGNATURE_SEMANTIC_NAME_MAX);
    2464 
    2465         VGPUSemanticInfo const *pSemanticInfo = dxbcSemanticInfo(pInfo, src->semanticName, u32BlobType);
    2466         dst->pcszSemanticName = pSemanticInfo->pszName;
    2467         dst->SemanticIndex = 0;
     2513        SVGA3dDXSignatureEntry *pSignatureEntry = &paSignature[iSignatureEntry];
     2514        DXShaderAttributeSemantic *pSemantic = &paSemantic[iSignatureEntry];
     2515
     2516        ASSERT_GUEST_RETURN_VOID(pSignatureEntry->semanticName < SVGADX_SIGNATURE_SEMANTIC_NAME_MAX);
     2517
     2518        VGPUSemanticInfo const *pSemanticInfo = dxbcSemanticInfo(pInfo, pSignatureEntry->semanticName, u32BlobType);
     2519        pSemantic->pcszSemanticName = pSemanticInfo->pszName;
     2520        pSemantic->SemanticIndex = 0;
     2521        if (pSignatureEntry->componentType == SVGADX_SIGNATURE_REGISTER_COMPONENT_UNKNOWN)
     2522            pSignatureEntry->componentType = pSemanticInfo->u32Type;
    24682523        for (uint32_t i = 0; i < iSignatureEntry; ++i)
    24692524        {
    2470             DXShaderAttributeSemantic const *pSemantic = &paSemantic[i];
    2471             if (RTStrCmp(pSemantic->pcszSemanticName, dst->pcszSemanticName) == 0)
    2472                 ++dst->SemanticIndex;
     2525            DXShaderAttributeSemantic const *pPriorSemantic = &paSemantic[i];
     2526            if (RTStrCmp(pPriorSemantic->pcszSemanticName, pSemantic->pcszSemanticName) == 0)
     2527                ++pSemantic->SemanticIndex;
    24732528        }
    24742529    }
     
    25202575        }
    25212576        dst->idxSemantic      = srcSemantic->SemanticIndex;
    2522         dst->enmSystemValue   = srcEntry->semanticName;
     2577        dst->enmSystemValue   = svga2dxSystemValue(srcEntry->semanticName);
    25232578        dst->enmComponentType = srcEntry->componentType;
    25242579        dst->idxRegister      = srcEntry->registerIndex;
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