OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 | 8 |
9 #include "GrGLCaps.h" | 9 #include "GrGLCaps.h" |
10 | 10 |
(...skipping 758 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 fStencilFormats.push_back() = gD24S8; | 769 fStencilFormats.push_back() = gD24S8; |
770 } | 770 } |
771 if (ctxInfo.hasExtension("GL_OES_stencil4")) { | 771 if (ctxInfo.hasExtension("GL_OES_stencil4")) { |
772 fStencilFormats.push_back() = gS4; | 772 fStencilFormats.push_back() = gS4; |
773 } | 773 } |
774 } | 774 } |
775 SkASSERT(0 == fStencilVerifiedColorConfigs.count()); | 775 SkASSERT(0 == fStencilVerifiedColorConfigs.count()); |
776 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count()); | 776 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count()); |
777 } | 777 } |
778 | 778 |
779 static GrGLenum precision_to_gl_float_type(GrShaderVar::Precision p) { | 779 static GrGLenum precision_to_gl_float_type(GrSLPrecision p) { |
780 switch (p) { | 780 switch (p) { |
781 case GrShaderVar::kLow_Precision: | 781 case kLow_GrSLPrecision: |
782 return GR_GL_LOW_FLOAT; | 782 return GR_GL_LOW_FLOAT; |
783 case GrShaderVar::kMedium_Precision: | 783 case kMedium_GrSLPrecision: |
784 return GR_GL_MEDIUM_FLOAT; | 784 return GR_GL_MEDIUM_FLOAT; |
785 case GrShaderVar::kHigh_Precision: | 785 case kHigh_GrSLPrecision: |
786 return GR_GL_HIGH_FLOAT; | 786 return GR_GL_HIGH_FLOAT; |
787 } | 787 } |
788 SkFAIL("Unknown precision."); | 788 SkFAIL("Unknown precision."); |
789 return -1; | 789 return -1; |
790 } | 790 } |
791 | 791 |
792 static GrGLenum shader_type_to_gl_shader(GrShaderType type) { | 792 static GrGLenum shader_type_to_gl_shader(GrShaderType type) { |
793 switch (type) { | 793 switch (type) { |
794 case kVertex_GrShaderType: | 794 case kVertex_GrShaderType: |
795 return GR_GL_VERTEX_SHADER; | 795 return GR_GL_VERTEX_SHADER; |
796 case kGeometry_GrShaderType: | 796 case kGeometry_GrShaderType: |
797 return GR_GL_GEOMETRY_SHADER; | 797 return GR_GL_GEOMETRY_SHADER; |
798 case kFragment_GrShaderType: | 798 case kFragment_GrShaderType: |
799 return GR_GL_FRAGMENT_SHADER; | 799 return GR_GL_FRAGMENT_SHADER; |
800 } | 800 } |
801 SkFAIL("Unknown shader type."); | 801 SkFAIL("Unknown shader type."); |
802 return -1; | 802 return -1; |
803 } | 803 } |
804 | 804 |
805 void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, const Gr
GLInterface* intf) { | 805 void GrGLCaps::initShaderPrecisionTable(const GrGLContextInfo& ctxInfo, const Gr
GLInterface* intf) { |
806 if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_V
ER(4,1) || | 806 if (kGLES_GrGLStandard == ctxInfo.standard() || ctxInfo.version() >= GR_GL_V
ER(4,1) || |
807 ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) { | 807 ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) { |
808 for (int s = 0; s < kGrShaderTypeCount; ++s) { | 808 for (int s = 0; s < kGrShaderTypeCount; ++s) { |
809 if (kGeometry_GrShaderType != s || fGeometryShaderSupport) { | 809 if (kGeometry_GrShaderType != s || fGeometryShaderSupport) { |
810 GrShaderType shaderType = static_cast<GrShaderType>(s); | 810 GrShaderType shaderType = static_cast<GrShaderType>(s); |
811 GrGLenum glShader = shader_type_to_gl_shader(shaderType); | 811 GrGLenum glShader = shader_type_to_gl_shader(shaderType); |
812 PrecisionInfo* first = NULL; | 812 PrecisionInfo* first = NULL; |
813 fShaderPrecisionVaries = false; | 813 fShaderPrecisionVaries = false; |
814 for (int p = 0; p < GrShaderVar::kPrecisionCount; ++p) { | 814 for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
815 GrShaderVar::Precision precision = static_cast<GrShaderVar::
Precision>(p); | 815 GrSLPrecision precision = static_cast<GrSLPrecision>(p); |
816 GrGLenum glPrecision = precision_to_gl_float_type(precision)
; | 816 GrGLenum glPrecision = precision_to_gl_float_type(precision)
; |
817 GrGLint range[2]; | 817 GrGLint range[2]; |
818 GrGLint bits; | 818 GrGLint bits; |
819 GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision,
range, &bits); | 819 GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision,
range, &bits); |
820 if (bits) { | 820 if (bits) { |
821 fFloatPrecisions[s][p].fLogRangeLow = range[0]; | 821 fFloatPrecisions[s][p].fLogRangeLow = range[0]; |
822 fFloatPrecisions[s][p].fLogRangeHigh = range[1]; | 822 fFloatPrecisions[s][p].fLogRangeHigh = range[1]; |
823 fFloatPrecisions[s][p].fBits = bits; | 823 fFloatPrecisions[s][p].fBits = bits; |
824 if (!first) { | 824 if (!first) { |
825 first = &fFloatPrecisions[s][p]; | 825 first = &fFloatPrecisions[s][p]; |
826 } else if (!fShaderPrecisionVaries) { | 826 } else if (!fShaderPrecisionVaries) { |
827 fShaderPrecisionVaries = (*first != fFloatPrecisions
[s][p]); | 827 fShaderPrecisionVaries = (*first != fFloatPrecisions
[s][p]); |
828 } | 828 } |
829 } | 829 } |
830 } | 830 } |
831 } | 831 } |
832 } | 832 } |
833 } else { | 833 } else { |
834 // We're on a desktop GL that doesn't have precision info. Assume they'r
e all 32bit float. | 834 // We're on a desktop GL that doesn't have precision info. Assume they'r
e all 32bit float. |
835 fShaderPrecisionVaries = false; | 835 fShaderPrecisionVaries = false; |
836 for (int s = 0; s < kGrShaderTypeCount; ++s) { | 836 for (int s = 0; s < kGrShaderTypeCount; ++s) { |
837 if (kGeometry_GrShaderType != s || fGeometryShaderSupport) { | 837 if (kGeometry_GrShaderType != s || fGeometryShaderSupport) { |
838 for (int p = 0; p < GrShaderVar::kPrecisionCount; ++p) { | 838 for (int p = 0; p < kGrSLPrecisionCount; ++p) { |
839 fFloatPrecisions[s][p].fLogRangeLow = 127; | 839 fFloatPrecisions[s][p].fLogRangeLow = 127; |
840 fFloatPrecisions[s][p].fLogRangeHigh = 127; | 840 fFloatPrecisions[s][p].fLogRangeHigh = 127; |
841 fFloatPrecisions[s][p].fBits = 23; | 841 fFloatPrecisions[s][p].fBits = 23; |
842 } | 842 } |
843 } | 843 } |
844 } | 844 } |
845 } | 845 } |
846 } | 846 } |
847 | 847 |
848 | 848 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); | 969 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); |
970 r.appendf("Fragment coord conventions support: %s\n", | 970 r.appendf("Fragment coord conventions support: %s\n", |
971 (fFragCoordsConventionSupport ? "YES": "NO")); | 971 (fFragCoordsConventionSupport ? "YES": "NO")); |
972 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); | 972 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ?
"YES": "NO")); |
973 r.appendf("Use non-VBO for dynamic data: %s\n", | 973 r.appendf("Use non-VBO for dynamic data: %s\n", |
974 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); | 974 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); |
975 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); | 975 r.appendf("Full screen clear is free: %s\n", (fFullClearIsFree ? "YES" : "NO
")); |
976 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); | 976 r.appendf("Drops tile on zero divide: %s\n", (fDropsTileOnZeroDivide ? "YES"
: "NO")); |
977 return r; | 977 return r; |
978 } | 978 } |
OLD | NEW |