Skip to content

Fix rendering when XrMaxViews is different than 2 #733

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public enum ShaderOptions
// Changing a value in this enum Config here require to regenerate the hlsl include and recompile C# and shaders
public class ShaderConfig
{
public const int k_XRMaxViewsForCBuffer = 2; // REALLY IMPORTANT! This needs to be the maximum possible XrMaxViews for any supported platform!
// this needs to be constant and not vary like XrMaxViews does as it is used to generate the cbuffer declarations

public static int s_CameraRelativeRendering = (int)ShaderOptions.CameraRelativeRendering;
public static int s_PreExposition = (int)ShaderOptions.PreExposition;
public static int s_XrMaxViews = (int)ShaderOptions.XrMaxViews;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ public enum ShaderOptions
// Changing a value in this enum Config here require to regenerate the hlsl include and recompile C# and shaders
public class ShaderConfig
{
public const int k_XRMaxViewsForCBuffer = 2; // REALLY IMPORTANT! This needs to be the maximum possible XrMaxViews for any supported platform!
// this needs to be constant and not vary like XrMaxViews does as it is used to generate the cbuffer declarations

public static int s_CameraRelativeRendering = (int)ShaderOptions.CameraRelativeRendering;
public static int s_PreExposition = (int)ShaderOptions.PreExposition;
public static int s_XrMaxViews = (int)ShaderOptions.XrMaxViews;
Expand Down
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed path traced DoF focusing issue
- Fix an issue with the half resolution Mode (performance)
- Fix an issue with the color intensity of emissive for performance rtgi
- Fixed issue with rendering being mostly broken when target platform disables VR.

### Changed
- Improve MIP selection for decals on Transparents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ public enum TileClusterCategoryDebug : int
[GenerateHLSL(needAccessors = false, generateCBuffer = true)]
unsafe struct ShaderVariablesLightList
{
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float g_mInvScrProjectionArr[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float g_mScrProjectionArr[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float g_mInvProjectionArr[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float g_mProjectionArr[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float g_mInvScrProjectionArr[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float g_mScrProjectionArr[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float g_mInvProjectionArr[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float g_mProjectionArr[ShaderConfig.k_XRMaxViewsForCBuffer * 16];

public Vector4 g_screenSize;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public static DensityVolumeEngineData GetNeutralValues()
[GenerateHLSL(needAccessors = false, generateCBuffer = true)]
unsafe struct ShaderVariablesVolumetric
{
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _VBufferCoordToViewDirWS[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _VBufferCoordToViewDirWS[ShaderConfig.k_XRMaxViewsForCBuffer * 16];

public float _VBufferUnitDepthTexelSpacing;
public uint _NumVisibleDensityVolumes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,35 @@ namespace UnityEngine.Rendering.HighDefinition
[GenerateHLSL(needAccessors = false, generateCBuffer = true, constantRegister = (int)ConstantRegister.XR)]
unsafe struct ShaderVariablesXR
{
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRViewMatrix[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRInvViewMatrix[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRInvProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRViewProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRInvViewProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRNonJitteredViewProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRPrevViewProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRPrevInvViewProjMatrix[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRPrevViewProjMatrixNoCameraTrans[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Matrix4x4))]
public fixed float _XRPixelCoordToViewDirWS[(int)ShaderOptions.XrMaxViews * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRViewMatrix[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRInvViewMatrix[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRProjMatrix[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRInvProjMatrix[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRViewProjMatrix[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRInvViewProjMatrix[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRNonJitteredViewProjMatrix[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRPrevViewProjMatrix[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRPrevInvViewProjMatrix[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRPrevViewProjMatrixNoCameraTrans[ShaderConfig.k_XRMaxViewsForCBuffer * 16];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Matrix4x4))]
public fixed float _XRPixelCoordToViewDirWS[ShaderConfig.k_XRMaxViewsForCBuffer * 16];


[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Vector4))]
public fixed float _XRWorldSpaceCameraPos[(int)ShaderOptions.XrMaxViews * 4];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Vector4))]
public fixed float _XRWorldSpaceCameraPosViewOffset[(int)ShaderOptions.XrMaxViews * 4];
[HLSLArray((int)ShaderOptions.XrMaxViews, typeof(Vector4))]
public fixed float _XRPrevWorldSpaceCameraPos[(int)ShaderOptions.XrMaxViews * 4];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Vector4))]
public fixed float _XRWorldSpaceCameraPos[ShaderConfig.k_XRMaxViewsForCBuffer * 4];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Vector4))]
public fixed float _XRWorldSpaceCameraPosViewOffset[ShaderConfig.k_XRMaxViewsForCBuffer * 4];
[HLSLArray(ShaderConfig.k_XRMaxViewsForCBuffer, typeof(Vector4))]
public fixed float _XRPrevWorldSpaceCameraPos[ShaderConfig.k_XRMaxViewsForCBuffer * 4];
}
}