Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: src/gpu/gl/GrGLCaps.cpp

Issue 778783002: Use texture size to determine precision of texture coord varyings (Closed) Base URL: https://skia.googlesource.com/skia.git@defaultp
Patch Set: include skrandom.h in new gm cpp Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 } 379 }
380 380
381 if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer() || 381 if (kPowerVR54x_GrGLRenderer == ctxInfo.renderer() ||
382 kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) { 382 kPowerVRRogue_GrGLRenderer == ctxInfo.renderer()) {
383 fUseDrawInsteadOfClear = true; 383 fUseDrawInsteadOfClear = true;
384 } 384 }
385 385
386 this->initConfigTexturableTable(ctxInfo, gli); 386 this->initConfigTexturableTable(ctxInfo, gli);
387 this->initConfigRenderableTable(ctxInfo); 387 this->initConfigRenderableTable(ctxInfo);
388 388
389 this->initShaderPrecisionTable(ctxInfo, gli);
390
389 return true; 391 return true;
390 } 392 }
391 393
392 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) { 394 void GrGLCaps::initConfigRenderableTable(const GrGLContextInfo& ctxInfo) {
393 // OpenGL < 3.0 395 // OpenGL < 3.0
394 // no support for render targets unless the GL_ARB_framebuffer_object 396 // no support for render targets unless the GL_ARB_framebuffer_object
395 // extension is supported (in which case we get ALPHA, RED, RG, RGB, 397 // extension is supported (in which case we get ALPHA, RED, RG, RGB,
396 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we 398 // RGBA (ALPHA8, RGBA4, RGBA8) for OpenGL > 1.1). Note that we
397 // probably don't get R8 in this case. 399 // probably don't get R8 in this case.
398 400
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
767 fStencilFormats.push_back() = gD24S8; 769 fStencilFormats.push_back() = gD24S8;
768 } 770 }
769 if (ctxInfo.hasExtension("GL_OES_stencil4")) { 771 if (ctxInfo.hasExtension("GL_OES_stencil4")) {
770 fStencilFormats.push_back() = gS4; 772 fStencilFormats.push_back() = gS4;
771 } 773 }
772 } 774 }
773 SkASSERT(0 == fStencilVerifiedColorConfigs.count()); 775 SkASSERT(0 == fStencilVerifiedColorConfigs.count());
774 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count()); 776 fStencilVerifiedColorConfigs.push_back_n(fStencilFormats.count());
775 } 777 }
776 778
779 static GrGLenum precision_to_gl_float_type(GrShaderVar::Precision p) {
780 switch (p) {
781 case GrShaderVar::kLow_Precision:
782 return GR_GL_LOW_FLOAT;
783 case GrShaderVar::kMedium_Precision:
784 return GR_GL_MEDIUM_FLOAT;
785 case GrShaderVar::kHigh_Precision:
786 return GR_GL_HIGH_FLOAT;
787 }
788 SkFAIL("Unknown precision.");
789 return -1;
790 }
791
792 static GrGLenum shader_type_to_gl_shader(GrShaderType type) {
793 switch (type) {
794 case kVertex_GrShaderType:
795 return GR_GL_VERTEX_SHADER;
796 case kGeometry_GrShaderType:
797 return GR_GL_GEOMETRY_SHADER;
798 case kFragment_GrShaderType:
799 return GR_GL_FRAGMENT_SHADER;
800 }
801 SkFAIL("Unknown shader type.");
802 return -1;
803 }
804
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) ||
807 ctxInfo.hasExtension("GL_ARB_ES2_compatibility")) {
808 for (int s = 0; s < kGrShaderTypeCount; ++s) {
809 if (kGeometry_GrShaderType != s || fGeometryShaderSupport) {
810 GrShaderType shaderType = static_cast<GrShaderType>(s);
811 GrGLenum glShader = shader_type_to_gl_shader(shaderType);
812 PrecisionInfo* first = NULL;
813 fShaderPrecisionVaries = false;
814 for (int p = 0; p < GrShaderVar::kPrecisionCount; ++p) {
815 GrShaderVar::Precision precision = static_cast<GrShaderVar:: Precision>(p);
816 GrGLenum glPrecision = precision_to_gl_float_type(precision) ;
817 GrGLint range[2];
818 GrGLint bits;
819 GR_GL_GetShaderPrecisionFormat(intf, glShader, glPrecision, range, &bits);
820 if (bits) {
821 fFloatPrecisions[s][p].fLogRangeLow = range[0];
822 fFloatPrecisions[s][p].fLogRangeHigh = range[1];
823 fFloatPrecisions[s][p].fBits = bits;
824 if (!first) {
825 first = &fFloatPrecisions[s][p];
826 } else if (!fShaderPrecisionVaries) {
827 fShaderPrecisionVaries = (*first != fFloatPrecisions [s][p]);
828 }
829 }
830 }
831 }
832 }
833 } else {
834 // We're on a desktop GL that doesn't have precision info. Assume they'r e all 32bit float.
835 fShaderPrecisionVaries = false;
836 for (int s = 0; s < kGrShaderTypeCount; ++s) {
837 if (kGeometry_GrShaderType != s || fGeometryShaderSupport) {
838 for (int p = 0; p < GrShaderVar::kPrecisionCount; ++p) {
839 fFloatPrecisions[s][p].fLogRangeLow = 127;
840 fFloatPrecisions[s][p].fLogRangeHigh = 127;
841 fFloatPrecisions[s][p].fBits = 23;
842 }
843 }
844 }
845 }
846 }
847
848
777 void GrGLCaps::markColorConfigAndStencilFormatAsVerified( 849 void GrGLCaps::markColorConfigAndStencilFormatAsVerified(
778 GrPixelConfig config, 850 GrPixelConfig config,
779 const GrGLStencilBuffer::Format& format) { 851 const GrGLStencilBuffer::Format& format) {
780 #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT 852 #if !GR_GL_CHECK_FBO_STATUS_ONCE_PER_FORMAT
781 return; 853 return;
782 #endif 854 #endif
783 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt); 855 SkASSERT((unsigned)config < (unsigned)kGrPixelConfigCnt);
784 SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count()); 856 SkASSERT(fStencilFormats.count() == fStencilVerifiedColorConfigs.count());
785 int count = fStencilFormats.count(); 857 int count = fStencilFormats.count();
786 // we expect a really small number of possible formats so linear search 858 // we expect a really small number of possible formats so linear search
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO")); 969 r.appendf("Two Format Limit: %s\n", (fTwoFormatLimit ? "YES": "NO"));
898 r.appendf("Fragment coord conventions support: %s\n", 970 r.appendf("Fragment coord conventions support: %s\n",
899 (fFragCoordsConventionSupport ? "YES": "NO")); 971 (fFragCoordsConventionSupport ? "YES": "NO"));
900 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO")); 972 r.appendf("Vertex array object support: %s\n", (fVertexArrayObjectSupport ? "YES": "NO"));
901 r.appendf("Use non-VBO for dynamic data: %s\n", 973 r.appendf("Use non-VBO for dynamic data: %s\n",
902 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO")); 974 (fUseNonVBOVertexAndIndexDynamicData ? "YES" : "NO"));
903 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 "));
904 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"));
905 return r; 977 return r;
906 } 978 }
OLDNEW
« no previous file with comments | « src/gpu/gl/GrGLCaps.h ('k') | src/gpu/gl/GrGLProgramDesc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698