@@ -105,7 +105,7 @@ namespace {
105105 // The number of frames since the mask was last used during a rendering pass.
106106 uint16_t age;
107107
108- std::shared_ptr<IShaderBuffer> cbShading[ViewCount + 2 ];
108+ std::shared_ptr<IShaderBuffer> cbShading[ViewCount * 2 + 2 ];
109109 std::shared_ptr<ITexture> mask[ViewCount + 1 ];
110110 std::shared_ptr<ITexture> maskDoubleWide;
111111 std::shared_ptr<ITexture> maskTextureArray;
@@ -129,11 +129,13 @@ namespace {
129129 uint32_t displayHeight,
130130 uint32_t tileSize,
131131 uint32_t tileRateMax,
132- bool hasVisibilityMask)
132+ bool hasVisibilityMask,
133+ bool needMirroredPattern)
133134 : m_openXR(openXR), m_configManager(configManager), m_device(graphicsDevice), m_eyeTracker(eyeTracker),
134135 m_renderWidth (renderWidth), m_renderHeight(renderHeight),
135136 m_renderRatio(float (renderWidth) / renderHeight), m_tileSize(tileSize), m_tileRateMax(tileRateMax),
136- m_actualRenderWidth(renderWidth), m_hasVisibilityMask(hasVisibilityMask) {
137+ m_actualRenderWidth(renderWidth), m_hasVisibilityMask(hasVisibilityMask),
138+ m_needMirroredPattern(needMirroredPattern) {
137139 createRenderResources (m_renderWidth, m_renderHeight);
138140
139141 // Set initial projection center
@@ -890,6 +892,20 @@ namespace {
890892 m_device->dispatchShader ();
891893 mask.mask [target]->setState (D3D12_RESOURCE_STATE_COPY_SOURCE);
892894 }
895+ if (m_usingEyeTracking && m_needMirroredPattern) {
896+ for (size_t i = 0 ; i < 2 ; i++) {
897+ const auto constants = makeShadingConstants (i, mask.widthInTiles , mask.heightInTiles , true );
898+ mask.cbShading [i]->uploadData (&constants, sizeof (constants));
899+
900+ m_csShading->updateThreadGroups ({dispatchX, dispatchY, 1 });
901+ m_device->setShader (m_csShading, SamplerType::NearestClamp);
902+ m_device->setShaderInput (0 , mask.cbShading [i]);
903+ mask.mask [i]->setState (D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
904+ m_device->setShaderOutput (0 , mask.mask [i]);
905+ m_device->dispatchShader ();
906+ mask.mask [i]->setState (D3D12_RESOURCE_STATE_COPY_SOURCE);
907+ }
908+ }
893909
894910 // Copy to the double wide/texture arrays mask.
895911 mask.mask [0 ]->copyTo (mask.maskDoubleWide , 0 , 0 , 0 );
@@ -904,9 +920,13 @@ namespace {
904920 TraceLoggingWriteStop (local, " VariableRateShading_UpdateMask" );
905921 }
906922
907- ShadingConstants makeShadingConstants (size_t eye, uint32_t texW, uint32_t texH) {
923+ ShadingConstants makeShadingConstants (size_t eye, uint32_t texW, uint32_t texH, bool upsideDown = false ) {
908924 ShadingConstants constants;
909- constants.GazeXY = m_gazeLocation[eye];
925+ if (!upsideDown) {
926+ constants.GazeXY = m_gazeLocation[eye];
927+ } else {
928+ constants.GazeXY = {m_gazeLocation[eye].x , -m_gazeLocation[eye].y };
929+ }
910930 constants.InvDim = {1 .f / texW, 1 .f / texH};
911931 for (size_t i = 0 ; i < std::size (m_Rings); i++) {
912932 constants.Rings [i] = m_Rings[i];
@@ -1052,6 +1072,7 @@ namespace {
10521072
10531073 XrSession m_session{XR_NULL_HANDLE};
10541074 bool m_usingEyeTracking{false };
1075+ bool m_needMirroredPattern{false };
10551076
10561077 std::map<uint32_t , uint32_t > m_renderScales;
10571078 uint32_t m_actualRenderWidth;
@@ -1141,7 +1162,8 @@ namespace toolkit::graphics {
11411162 uint32_t renderHeight,
11421163 uint32_t displayWidth,
11431164 uint32_t displayHeight,
1144- bool hasVisibilityMask) {
1165+ bool hasVisibilityMask,
1166+ bool needMirroredPattern) {
11451167 try {
11461168 uint32_t tileSize = 0 ;
11471169 uint32_t tileRateMax = 0 ;
@@ -1207,7 +1229,8 @@ namespace toolkit::graphics {
12071229 displayHeight,
12081230 tileSize,
12091231 tileRateMax,
1210- hasVisibilityMask);
1232+ hasVisibilityMask,
1233+ needMirroredPattern);
12111234
12121235 } catch (FeatureNotSupported&) {
12131236 return nullptr ;
0 commit comments