@@ -528,7 +528,7 @@ void CxbxUpdateHostViewPortOffsetAndScaleConstants()
528528 // With draws going through pfifo, the PGRAPH values ARE the source of
529529 // truth — they are written before the draw in the push buffer and
530530 // processed sequentially by the puller. CxbxUpdateHostVertexShaderConstants
531- // already uploads them from pg->vsh_constants [58/59].
531+ // already uploads them from pg->xf.xfctx [58/59].
532532 //
533533 // TODO: Re-enable this overwrite if HLE draw patches are restored.
534534 // Test Case: GTA III, Soldier of Fortune II (needed when HLE draws are active)
@@ -673,7 +673,7 @@ void UpdateFixedFunctionVertexShaderState()
673673 // Helper: direct-copy a 4x4 matrix from vsh_constants[base..base+3] — NO transpose
674674 auto ReadXFCTXMatrix = [&](D3DXMATRIX* pDst, int base) {
675675 for (int row = 0 ; row < 4 ; row++) {
676- std::memcpy (&pDst->m [row][0 ], &pg->vsh_constants [base + row][0 ], 16 );
676+ std::memcpy (&pDst->m [row][0 ], &pg->xf . xfctx [base + row][0 ], 16 );
677677 }
678678 };
679679
@@ -685,7 +685,7 @@ void UpdateFixedFunctionVertexShaderState()
685685 // Read viewport offset from PGRAPH XFCTX (half-pixel bias applied by Xbox runtime)
686686 float vpoff[4 ];
687687 for (int i = 0 ; i < 4 ; i++) {
688- std::memcpy (&vpoff[i], &pg->vsh_constants [NV_IGRAPH_XF_XFCTX_VPOFF][i], sizeof (float ));
688+ std::memcpy (&vpoff[i], &pg->xf . xfctx [NV_IGRAPH_XF_XFCTX_VPOFF][i], sizeof (float ));
689689 }
690690
691691 // NV2A FF pipeline: CMAT × position → screen-space coordinates (viewport baked in).
@@ -963,68 +963,68 @@ void UpdateFixedFunctionVertexShaderState()
963963 // Diffuse color from ltctxb (3 floats stored as uint32_t bit patterns)
964964 int base = NV_IGRAPH_XF_LTCTXB_L0_DIF + (int )i * 6 ;
965965 pShaderLight->Diffuse = D3DXVECTOR4 (
966- AsFloat (pg->ltctxb [base][0 ]),
967- AsFloat (pg->ltctxb [base][1 ]),
968- AsFloat (pg->ltctxb [base][2 ]),
966+ AsFloat (pg->xf . ltctxb [base][0 ]),
967+ AsFloat (pg->xf . ltctxb [base][1 ]),
968+ AsFloat (pg->xf . ltctxb [base][2 ]),
969969 1 .0f );
970970
971971 // Specular color
972972 bool SpecularEnable = (csv0c & NV_PGRAPH_CSV0_C_SPECULAR_ENABLE) != 0 ;
973973 base = NV_IGRAPH_XF_LTCTXB_L0_SPC + (int )i * 6 ;
974974 if (SpecularEnable) {
975975 pShaderLight->Specular = D3DXVECTOR4 (
976- AsFloat (pg->ltctxb [base][0 ]),
977- AsFloat (pg->ltctxb [base][1 ]),
978- AsFloat (pg->ltctxb [base][2 ]),
976+ AsFloat (pg->xf . ltctxb [base][0 ]),
977+ AsFloat (pg->xf . ltctxb [base][1 ]),
978+ AsFloat (pg->xf . ltctxb [base][2 ]),
979979 1 .0f );
980980 } else {
981981 pShaderLight->Specular = D3DXVECTOR4 (0 , 0 , 0 , 0 );
982982 }
983983
984984 // Accumulate per-light ambient
985985 base = NV_IGRAPH_XF_LTCTXB_L0_AMB + (int )i * 6 ;
986- LightAmbient.x += AsFloat (pg->ltctxb [base][0 ]);
987- LightAmbient.y += AsFloat (pg->ltctxb [base][1 ]);
988- LightAmbient.z += AsFloat (pg->ltctxb [base][2 ]);
986+ LightAmbient.x += AsFloat (pg->xf . ltctxb [base][0 ]);
987+ LightAmbient.y += AsFloat (pg->xf . ltctxb [base][1 ]);
988+ LightAmbient.z += AsFloat (pg->xf . ltctxb [base][2 ]);
989989
990990 // Direction (for directional lights — already in view-space, normalized)
991991 pShaderLight->DirectionVN = D3DXVECTOR3 (
992- pg->light_infinite_direction [i][0 ],
993- pg->light_infinite_direction [i][1 ],
994- pg->light_infinite_direction [i][2 ]);
992+ pg->light [i]. infinite_direction [0 ],
993+ pg->light [i]. infinite_direction [1 ],
994+ pg->light [i]. infinite_direction [2 ]);
995995
996996 // Position (for point/spot lights — already in view-space)
997997 pShaderLight->PositionV = D3DXVECTOR3 (
998- pg->light_local_position [i][0 ],
999- pg->light_local_position [i][1 ],
1000- pg->light_local_position [i][2 ]);
998+ pg->light [i]. local_position [0 ],
999+ pg->light [i]. local_position [1 ],
1000+ pg->light [i]. local_position [2 ]);
10011001
10021002 // Attenuation
10031003 pShaderLight->Attenuation = D3DXVECTOR3 (
1004- pg->light_local_attenuation [i][0 ],
1005- pg->light_local_attenuation [i][1 ],
1006- pg->light_local_attenuation [i][2 ]);
1004+ pg->light [i]. local_attenuation [0 ],
1005+ pg->light [i]. local_attenuation [1 ],
1006+ pg->light [i]. local_attenuation [2 ]);
10071007
10081008 // Range (stored in ltc1)
1009- pShaderLight->Range = AsFloat (pg->ltc1 [NV_IGRAPH_XF_LTC1_r0 + i][0 ]);
1009+ pShaderLight->Range = AsFloat (pg->xf . ltc1 [NV_IGRAPH_XF_LTC1_r0 + i][0 ]);
10101010
10111011 // Spot parameters from ltctxa
10121012 int spotBase = NV_IGRAPH_XF_LTCTXA_L0_K + (int )i * 2 ;
1013- pShaderLight->Falloff = AsFloat (pg->ltctxa [spotBase][2 ]); // falloff stored in K[2]
1014- pShaderLight->CosHalfPhi = AsFloat (pg->ltctxa [spotBase][0 ]);
1015- pShaderLight->SpotIntensityDivisor = AsFloat (pg->ltctxa [spotBase][1 ]);
1013+ pShaderLight->Falloff = AsFloat (pg->xf . ltctxa [spotBase][2 ]); // falloff stored in K[2]
1014+ pShaderLight->CosHalfPhi = AsFloat (pg->xf . ltctxa [spotBase][0 ]);
1015+ pShaderLight->SpotIntensityDivisor = AsFloat (pg->xf . ltctxa [spotBase][1 ]);
10161016 }
10171017
10181018 // Scene ambient from PGRAPH ltctxa[FR_AMB] (3 floats)
10191019 D3DXVECTOR4 SceneAmbient (
1020- AsFloat (pg->ltctxa [NV_IGRAPH_XF_LTCTXA_FR_AMB][0 ]),
1021- AsFloat (pg->ltctxa [NV_IGRAPH_XF_LTCTXA_FR_AMB][1 ]),
1022- AsFloat (pg->ltctxa [NV_IGRAPH_XF_LTCTXA_FR_AMB][2 ]),
1020+ AsFloat (pg->xf . ltctxa [NV_IGRAPH_XF_LTCTXA_FR_AMB][0 ]),
1021+ AsFloat (pg->xf . ltctxa [NV_IGRAPH_XF_LTCTXA_FR_AMB][1 ]),
1022+ AsFloat (pg->xf . ltctxa [NV_IGRAPH_XF_LTCTXA_FR_AMB][2 ]),
10231023 0 .f );
10241024 D3DXVECTOR4 BackSceneAmbient (
1025- AsFloat (pg->ltctxa [NV_IGRAPH_XF_LTCTXA_BR_AMB][0 ]),
1026- AsFloat (pg->ltctxa [NV_IGRAPH_XF_LTCTXA_BR_AMB][1 ]),
1027- AsFloat (pg->ltctxa [NV_IGRAPH_XF_LTCTXA_BR_AMB][2 ]),
1025+ AsFloat (pg->xf . ltctxa [NV_IGRAPH_XF_LTCTXA_BR_AMB][0 ]),
1026+ AsFloat (pg->xf . ltctxa [NV_IGRAPH_XF_LTCTXA_BR_AMB][1 ]),
1027+ AsFloat (pg->xf . ltctxa [NV_IGRAPH_XF_LTCTXA_BR_AMB][2 ]),
10281028 0 .f );
10291029
10301030 ffShaderState.TotalLightsAmbient .Front = (D3DXVECTOR3)(LightAmbient + SceneAmbient);
@@ -1034,8 +1034,8 @@ void UpdateFixedFunctionVertexShaderState()
10341034 // The shader computes (material * light), so white material preserves the pre-multiplied values.
10351035 // Emission is already baked into the scene ambient register (FR_AMB/BR_AMB) by the Xbox D3D runtime.
10361036 // Material alpha comes from NV097_SET_MATERIAL_ALPHA → ltctxa[CM_COL][3].
1037- float materialAlpha = AsFloat (pg->ltctxa [NV_IGRAPH_XF_LTCTXA_CM_COL][3 ]);
1038- float backMaterialAlpha = AsFloat (pg->ltctxa [NV_IGRAPH_XF_LTCTXA_BCM_COL][3 ]);
1037+ float materialAlpha = AsFloat (pg->xf . ltctxa [NV_IGRAPH_XF_LTCTXA_CM_COL][3 ]);
1038+ float backMaterialAlpha = AsFloat (pg->xf . ltctxa [NV_IGRAPH_XF_LTCTXA_BCM_COL][3 ]);
10391039
10401040 ffShaderState.Materials [0 ].Diffuse = D3DXVECTOR4 (1 , 1 , 1 , materialAlpha);
10411041 ffShaderState.Materials [0 ].Ambient = D3DXVECTOR4 (1 , 1 , 1 , 1 );
@@ -1045,17 +1045,17 @@ void UpdateFixedFunctionVertexShaderState()
10451045 // Reconstruct specular power from NV2A's 6 polynomial coefficients (LTC1).
10461046 // Front specular params: ltc1[l0][0..3] + ltc1[l0+1][0..1]
10471047 float frontParams[6 ];
1048- for (int j = 0 ; j < 4 ; j++) frontParams[j] = AsFloat (pg->ltc1 [NV_IGRAPH_XF_LTC1_l0][j]);
1049- for (int j = 0 ; j < 2 ; j++) frontParams[4 + j] = AsFloat (pg->ltc1 [NV_IGRAPH_XF_LTC1_l0 + 1 ][j]);
1048+ for (int j = 0 ; j < 4 ; j++) frontParams[j] = AsFloat (pg->xf . ltc1 [NV_IGRAPH_XF_LTC1_l0][j]);
1049+ for (int j = 0 ; j < 2 ; j++) frontParams[4 + j] = AsFloat (pg->xf . ltc1 [NV_IGRAPH_XF_LTC1_l0 + 1 ][j]);
10501050 ffShaderState.Materials [0 ].Power = ReconstructSpecularPower (frontParams);
10511051
10521052 ffShaderState.Materials [1 ] = ffShaderState.Materials [0 ]; // back material (start from front)
10531053 ffShaderState.Materials [1 ].Diffuse .w = backMaterialAlpha;
10541054
10551055 // Back specular params: ltc1[Bl0][0..3] + ltc1[Bl0+1][0..1]
10561056 float backParams[6 ];
1057- for (int j = 0 ; j < 4 ; j++) backParams[j] = AsFloat (pg->ltc1 [NV_IGRAPH_XF_LTC1_Bl0][j]);
1058- for (int j = 0 ; j < 2 ; j++) backParams[4 + j] = AsFloat (pg->ltc1 [NV_IGRAPH_XF_LTC1_Bl0 + 1 ][j]);
1057+ for (int j = 0 ; j < 4 ; j++) backParams[j] = AsFloat (pg->xf . ltc1 [NV_IGRAPH_XF_LTC1_Bl0][j]);
1058+ for (int j = 0 ; j < 2 ; j++) backParams[4 + j] = AsFloat (pg->xf . ltc1 [NV_IGRAPH_XF_LTC1_Bl0 + 1 ][j]);
10591059 ffShaderState.Materials [1 ].Power = ReconstructSpecularPower (backParams);
10601060 }
10611061
0 commit comments