From cdfdf1c094a870e017606d003c3ecdeb9215df16 Mon Sep 17 00:00:00 2001 From: Unity Technologies <@unity.com> Date: Wed, 10 Jul 2019 02:17:32 +0000 Subject: [PATCH] com.unity.render-pipelines.core@1.1.11-preview --- CoreRP/ShaderLibrary/UnityInstancing.hlsl | 25 +++++++++++++++++++---- package.json | 2 +- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/CoreRP/ShaderLibrary/UnityInstancing.hlsl b/CoreRP/ShaderLibrary/UnityInstancing.hlsl index 219ed0a..be46cc0 100644 --- a/CoreRP/ShaderLibrary/UnityInstancing.hlsl +++ b/CoreRP/ShaderLibrary/UnityInstancing.hlsl @@ -9,7 +9,7 @@ #define UNITY_SUPPORT_INSTANCING #endif -#if defined(SHADER_API_D3D11) +#if defined(SHADER_API_D3D11) || defined(SHADER_API_GLCORE) || defined(SHADER_API_GLES3) #define UNITY_SUPPORT_STEREO_INSTANCING #endif @@ -92,8 +92,13 @@ // - UNITY_TRANSFER_VERTEX_OUTPUT_STEREO Copy stero target from input struct to output struct. Used in vertex shader. // - UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX #ifdef UNITY_STEREO_INSTANCING_ENABLED +#if defined(SHADER_API_GLES3) || defined(SHADER_API_GLCORE) + #define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO uint stereoTargetEyeIndexSV : SV_RenderTargetArrayIndex; uint stereoTargetEyeIndex : BLENDINDICES0; + #define DEFAULT_UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output) output.stereoTargetEyeIndexSV = unity_StereoEyeIndex; output.stereoTargetEyeIndex = unity_StereoEyeIndex; +#else #define DEFAULT_UNITY_VERTEX_OUTPUT_STEREO uint stereoTargetEyeIndex : SV_RenderTargetArrayIndex; #define DEFAULT_UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output) output.stereoTargetEyeIndex = unity_StereoEyeIndex +#endif #define DEFAULT_UNITY_TRANSFER_VERTEX_OUTPUT_STEREO(input, output) output.stereoTargetEyeIndex = input.stereoTargetEyeIndex; #define DEFAULT_UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input) unity_StereoEyeIndex = input.stereoTargetEyeIndex; #elif defined(UNITY_STEREO_MULTIVIEW_ENABLED) @@ -137,9 +142,21 @@ void UnitySetupInstanceID(uint inputInstanceID) { #ifdef UNITY_STEREO_INSTANCING_ENABLED - // stereo eye index is automatically figured out from the instance ID - unity_StereoEyeIndex = inputInstanceID & 0x01; - unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1); + #if defined(SHADER_API_GLES3) + // We must calculate the stereo eye index differently for GLES3 + // because otherwise, the unity shader compiler will emit a bitfieldInsert function. + // bitfieldInsert requires support for glsl version 400 or later. Therefore the + // generated glsl code will fail to compile on lower end devices. By changing the + // way we calculate the stereo eye index, we can help the shader compiler to avoid + // emitting the bitfieldInsert function and thereby increase the number of devices we + // can run stereo instancing on. + unity_StereoEyeIndex = round(fmod(inputInstanceID, 2.0)); + unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1); + #else + // stereo eye index is automatically figured out from the instance ID + unity_StereoEyeIndex = inputInstanceID & 0x01; + unity_InstanceID = unity_BaseInstanceID + (inputInstanceID >> 1); + #endif #else unity_InstanceID = inputInstanceID + unity_BaseInstanceID; #endif diff --git a/package.json b/package.json index 490874f..398a58a 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "com.unity.render-pipelines.core", "displayName": "SRP Core", "description": "Core library for Unity render pipelines.", - "version": "1.1.10-preview", + "version": "1.1.11-preview", "unity": "2018.1", "dependencies": { "com.unity.postprocessing": "2.0.7-preview"