ESSL: Fix #1823: Conditions for when derivatives are in compute shader.
diff --git a/Test/320.comp b/Test/320.comp
index c31b047..5b38995 100644
--- a/Test/320.comp
+++ b/Test/320.comp
@@ -1,5 +1,17 @@
 #version 320 es

+
+float fX;
+float fY;
 

 void main()
 {
+    dFdx(fX);
+    dFdy(fY);
+    fwidth(fX);
+    dFdxCoarse(fX);
+    dFdyCoarse(fY);
+    fwidthCoarse(fX);
+    dFdxFine(fX);
+    dFdyFine(fY);
+    fwidthFine(fX);
 }
diff --git a/Test/baseResults/320.comp.out b/Test/baseResults/320.comp.out
index 09cedd0..00865be 100644
--- a/Test/baseResults/320.comp.out
+++ b/Test/baseResults/320.comp.out
@@ -1,10 +1,43 @@
 320.comp
+ERROR: 0:8: 'dFdx' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:9: 'dFdy' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:10: 'fwidth' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:11: 'dFdxCoarse' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:12: 'dFdyCoarse' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:13: 'fwidthCoarse' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:14: 'dFdxFine' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:15: 'dFdyFine' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 0:16: 'fwidthFine' : required extension not requested: GL_NV_compute_shader_derivatives
+ERROR: 9 compilation errors.  No code generated.
+
+
 Shader version: 320
 local_size = (1, 1, 1)
-0:? Sequence
-0:3  Function Definition: main( ( global void)
-0:3    Function Parameters: 
+ERROR: node is still EOpNull!
+0:6  Function Definition: main( ( global void)
+0:6    Function Parameters: 
+0:8    Sequence
+0:8      dPdx ( global highp float)
+0:8        'fX' ( global highp float)
+0:9      dPdy ( global highp float)
+0:9        'fY' ( global highp float)
+0:10      fwidth ( global highp float)
+0:10        'fX' ( global highp float)
+0:11      dPdxCoarse ( global highp float)
+0:11        'fX' ( global highp float)
+0:12      dPdyCoarse ( global highp float)
+0:12        'fY' ( global highp float)
+0:13      fwidthCoarse ( global highp float)
+0:13        'fX' ( global highp float)
+0:14      dPdxFine ( global highp float)
+0:14        'fX' ( global highp float)
+0:15      dPdyFine ( global highp float)
+0:15        'fY' ( global highp float)
+0:16      fwidthFine ( global highp float)
+0:16        'fX' ( global highp float)
 0:?   Linker Objects
+0:?     'fX' ( global highp float)
+0:?     'fY' ( global highp float)
 
 
 Linked compute stage:
@@ -12,8 +45,29 @@
 
 Shader version: 320
 local_size = (1, 1, 1)
-0:? Sequence
-0:3  Function Definition: main( ( global void)
-0:3    Function Parameters: 
+ERROR: node is still EOpNull!
+0:6  Function Definition: main( ( global void)
+0:6    Function Parameters: 
+0:8    Sequence
+0:8      dPdx ( global highp float)
+0:8        'fX' ( global highp float)
+0:9      dPdy ( global highp float)
+0:9        'fY' ( global highp float)
+0:10      fwidth ( global highp float)
+0:10        'fX' ( global highp float)
+0:11      dPdxCoarse ( global highp float)
+0:11        'fX' ( global highp float)
+0:12      dPdyCoarse ( global highp float)
+0:12        'fY' ( global highp float)
+0:13      fwidthCoarse ( global highp float)
+0:13        'fX' ( global highp float)
+0:14      dPdxFine ( global highp float)
+0:14        'fX' ( global highp float)
+0:15      dPdyFine ( global highp float)
+0:15        'fY' ( global highp float)
+0:16      fwidthFine ( global highp float)
+0:16        'fX' ( global highp float)
 0:?   Linker Objects
+0:?     'fX' ( global highp float)
+0:?     'fY' ( global highp float)
 
diff --git a/glslang/MachineIndependent/Initialize.cpp b/glslang/MachineIndependent/Initialize.cpp
index fddb1d1..3d3e108 100644
--- a/glslang/MachineIndependent/Initialize.cpp
+++ b/glslang/MachineIndependent/Initialize.cpp
@@ -5144,14 +5144,12 @@
     }
 
     //E_SPV_NV_compute_shader_derivatives
-    
-    stageBuiltins[EShLangCompute].append(derivatives);
-    stageBuiltins[EShLangCompute].append(derivativeControls);
-    stageBuiltins[EShLangCompute].append("\n");
-    
-
+    if (profile == EEsProfile && version >= 320 || profile != EEsProfile && version >= 450) {
+        stageBuiltins[EShLangCompute].append(derivatives);
+        stageBuiltins[EShLangCompute].append(derivativeControls);
+        stageBuiltins[EShLangCompute].append("\n");
+    }
     if (profile != EEsProfile && version >= 450) {
-
         stageBuiltins[EShLangCompute].append(derivativesAndControl16bits);
         stageBuiltins[EShLangCompute].append(derivativesAndControl64bits);
         stageBuiltins[EShLangCompute].append("\n");
@@ -8443,19 +8441,6 @@
             BuiltInVariable("gl_BaryCoordNV",        EbvBaryCoordNV,        symbolTable);
             BuiltInVariable("gl_BaryCoordNoPerspNV", EbvBaryCoordNoPerspNV, symbolTable);
         }
-        if (((profile != EEsProfile && version >= 450) ||
-            (profile == EEsProfile && version >= 320)) &&
-            language == EShLangCompute) {
-            symbolTable.setFunctionExtensions("dFdx",                   1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("dFdy",                   1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("fwidth",                 1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("dFdxFine",               1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("dFdyFine",               1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("fwidthFine",             1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("dFdxCoarse",             1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("dFdyCoarse",             1, &E_GL_NV_compute_shader_derivatives);
-            symbolTable.setFunctionExtensions("fwidthCoarse",           1, &E_GL_NV_compute_shader_derivatives);
-        }
 #endif
 
         if ((profile != EEsProfile && version >= 450) ||
@@ -8774,6 +8759,20 @@
         symbolTable.setFunctionExtensions("coopMatStoreNV",             1, &E_GL_NV_cooperative_matrix);
         symbolTable.setFunctionExtensions("coopMatMulAddNV",            1, &E_GL_NV_cooperative_matrix);
 
+#ifdef NV_EXTENSIONS
+        if ((profile != EEsProfile && version >= 450) || (profile == EEsProfile && version >= 320)) {
+            symbolTable.setFunctionExtensions("dFdx",                   1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("dFdy",                   1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("fwidth",                 1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("dFdxFine",               1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("dFdyFine",               1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("fwidthFine",             1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("dFdxCoarse",             1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("dFdyCoarse",             1, &E_GL_NV_compute_shader_derivatives);
+            symbolTable.setFunctionExtensions("fwidthCoarse",           1, &E_GL_NV_compute_shader_derivatives);
+        }
+#endif
+
         break;
 #ifdef NV_EXTENSIONS
     case EShLangRayGenNV: