OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2010 Google Inc. | 3 * Copyright 2010 Google Inc. |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 #include "GrDrawTarget.h" | 9 #include "GrDrawTarget.h" |
10 | 10 |
11 #include "GrAARectRenderer.h" | 11 #include "GrAARectRenderer.h" |
12 #include "GrBatch.h" | 12 #include "GrBatch.h" |
13 #include "GrCaps.h" | 13 #include "GrCaps.h" |
14 #include "GrContext.h" | 14 #include "GrContext.h" |
15 #include "GrContextOptions.h" | |
16 #include "GrPath.h" | 15 #include "GrPath.h" |
17 #include "GrPipeline.h" | 16 #include "GrPipeline.h" |
18 #include "GrMemoryPool.h" | 17 #include "GrMemoryPool.h" |
19 #include "GrRectBatch.h" | 18 #include "GrRectBatch.h" |
20 #include "GrRenderTarget.h" | 19 #include "GrRenderTarget.h" |
21 #include "GrRenderTargetPriv.h" | 20 #include "GrRenderTargetPriv.h" |
22 #include "GrSurfacePriv.h" | 21 #include "GrSurfacePriv.h" |
23 #include "GrTemplates.h" | 22 #include "GrTemplates.h" |
24 #include "GrTexture.h" | 23 #include "GrTexture.h" |
25 #include "GrVertexBuffer.h" | 24 #include "GrVertexBuffer.h" |
(...skipping 21 matching lines...) Expand all Loading... |
47 GrXferProcessor::DstTexture* dstTextu
re, | 46 GrXferProcessor::DstTexture* dstTextu
re, |
48 const SkRect* drawBounds) { | 47 const SkRect* drawBounds) { |
49 if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), colorPOI, coverageP
OI)) { | 48 if (!pipelineBuilder.willXPNeedDstTexture(*this->caps(), colorPOI, coverageP
OI)) { |
50 return true; | 49 return true; |
51 } | 50 } |
52 | 51 |
53 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); | 52 GrRenderTarget* rt = pipelineBuilder.getRenderTarget(); |
54 | 53 |
55 if (this->caps()->textureBarrierSupport()) { | 54 if (this->caps()->textureBarrierSupport()) { |
56 if (GrTexture* rtTex = rt->asTexture()) { | 55 if (GrTexture* rtTex = rt->asTexture()) { |
57 // The render target is a texture, se we can read from it directly i
n the shader. The XP | 56 // The render target is a texture, so we can read from it directly i
n the shader. The XP |
58 // will be responsible to detect this situation and request a textur
e barrier. | 57 // will be responsible to detect this situation and request a textur
e barrier. |
59 dstTexture->setTexture(rtTex); | 58 dstTexture->setTexture(rtTex); |
60 dstTexture->setOffset(0, 0); | 59 dstTexture->setOffset(0, 0); |
61 return true; | 60 return true; |
62 } | 61 } |
63 } | 62 } |
64 | 63 |
65 SkIRect copyRect; | 64 SkIRect copyRect; |
66 pipelineBuilder.clip().getConservativeBounds(rt, ©Rect); | 65 pipelineBuilder.clip().getConservativeBounds(rt, ©Rect); |
67 | 66 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 fColorPOI = fPipelineBuilder->colorProcInfo(batch); | 534 fColorPOI = fPipelineBuilder->colorProcInfo(batch); |
536 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch); | 535 fCoveragePOI = fPipelineBuilder->coverageProcInfo(batch); |
537 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage
POI, | 536 if (!target->setupDstReadIfNecessary(*fPipelineBuilder, fColorPOI, fCoverage
POI, |
538 &fDstTexture, devBounds)) { | 537 &fDstTexture, devBounds)) { |
539 fPipelineBuilder = NULL; | 538 fPipelineBuilder = NULL; |
540 } | 539 } |
541 } | 540 } |
542 | 541 |
543 /////////////////////////////////////////////////////////////////////////////// | 542 /////////////////////////////////////////////////////////////////////////////// |
544 | 543 |
545 GrShaderCaps::GrShaderCaps() { | |
546 fShaderDerivativeSupport = false; | |
547 fGeometryShaderSupport = false; | |
548 fPathRenderingSupport = false; | |
549 fDstReadInShaderSupport = false; | |
550 fDualSourceBlendingSupport = false; | |
551 fMixedSamplesSupport = false; | |
552 fShaderPrecisionVaries = false; | |
553 } | |
554 | |
555 static const char* shader_type_to_string(GrShaderType type) { | |
556 switch (type) { | |
557 case kVertex_GrShaderType: | |
558 return "vertex"; | |
559 case kGeometry_GrShaderType: | |
560 return "geometry"; | |
561 case kFragment_GrShaderType: | |
562 return "fragment"; | |
563 } | |
564 return ""; | |
565 } | |
566 | |
567 static const char* precision_to_string(GrSLPrecision p) { | |
568 switch (p) { | |
569 case kLow_GrSLPrecision: | |
570 return "low"; | |
571 case kMedium_GrSLPrecision: | |
572 return "medium"; | |
573 case kHigh_GrSLPrecision: | |
574 return "high"; | |
575 } | |
576 return ""; | |
577 } | |
578 | |
579 SkString GrShaderCaps::dump() const { | |
580 SkString r; | |
581 static const char* gNY[] = { "NO", "YES" }; | |
582 r.appendf("Shader Derivative Support : %s\n", gNY[fShaderDerivative
Support]); | |
583 r.appendf("Geometry Shader Support : %s\n", gNY[fGeometryShaderSu
pport]); | |
584 r.appendf("Path Rendering Support : %s\n", gNY[fPathRenderingSup
port]); | |
585 r.appendf("Dst Read In Shader Support : %s\n", gNY[fDstReadInShaderS
upport]); | |
586 r.appendf("Dual Source Blending Support : %s\n", gNY[fDualSourceBlendi
ngSupport]); | |
587 r.appendf("Mixed Samples Support : %s\n", gNY[fMixedSamplesSupp
ort]); | |
588 | |
589 r.appendf("Shader Float Precisions (varies: %s):\n", gNY[fShaderPrecisionVar
ies]); | |
590 | |
591 for (int s = 0; s < kGrShaderTypeCount; ++s) { | |
592 GrShaderType shaderType = static_cast<GrShaderType>(s); | |
593 r.appendf("\t%s:\n", shader_type_to_string(shaderType)); | |
594 for (int p = 0; p < kGrSLPrecisionCount; ++p) { | |
595 if (fFloatPrecisions[s][p].supported()) { | |
596 GrSLPrecision precision = static_cast<GrSLPrecision>(p); | |
597 r.appendf("\t\t%s: log_low: %d log_high: %d bits: %d\n", | |
598 precision_to_string(precision), | |
599 fFloatPrecisions[s][p].fLogRangeLow, | |
600 fFloatPrecisions[s][p].fLogRangeHigh, | |
601 fFloatPrecisions[s][p].fBits); | |
602 } | |
603 } | |
604 } | |
605 | |
606 return r; | |
607 } | |
608 | |
609 /////////////////////////////////////////////////////////////////////////////// | |
610 | |
611 GrCaps::GrCaps(const GrContextOptions& options) { | |
612 fMipMapSupport = false; | |
613 fNPOTTextureTileSupport = false; | |
614 fTwoSidedStencilSupport = false; | |
615 fStencilWrapOpsSupport = false; | |
616 fDiscardRenderTargetSupport = false; | |
617 fReuseScratchTextures = true; | |
618 fGpuTracingSupport = false; | |
619 fCompressedTexSubImageSupport = false; | |
620 fOversizedStencilSupport = false; | |
621 fTextureBarrierSupport = false; | |
622 | |
623 fUseDrawInsteadOfClear = false; | |
624 | |
625 fBlendEquationSupport = kBasic_BlendEquationSupport; | |
626 fMapBufferFlags = kNone_MapFlags; | |
627 | |
628 fMaxRenderTargetSize = 0; | |
629 fMaxTextureSize = 0; | |
630 fMaxSampleCount = 0; | |
631 | |
632 memset(fConfigRenderSupport, 0, sizeof(fConfigRenderSupport)); | |
633 memset(fConfigTextureSupport, 0, sizeof(fConfigTextureSupport)); | |
634 | |
635 fSupressPrints = options.fSuppressPrints; | |
636 fDrawPathMasksToCompressedTextureSupport = options.fDrawPathToCompressedText
ure; | |
637 } | |
638 | |
639 static SkString map_flags_to_string(uint32_t flags) { | |
640 SkString str; | |
641 if (GrCaps::kNone_MapFlags == flags) { | |
642 str = "none"; | |
643 } else { | |
644 SkASSERT(GrCaps::kCanMap_MapFlag & flags); | |
645 SkDEBUGCODE(flags &= ~GrCaps::kCanMap_MapFlag); | |
646 str = "can_map"; | |
647 | |
648 if (GrCaps::kSubset_MapFlag & flags) { | |
649 str.append(" partial"); | |
650 } else { | |
651 str.append(" full"); | |
652 } | |
653 SkDEBUGCODE(flags &= ~GrCaps::kSubset_MapFlag); | |
654 } | |
655 SkASSERT(0 == flags); // Make sure we handled all the flags. | |
656 return str; | |
657 } | |
658 | |
659 SkString GrCaps::dump() const { | |
660 SkString r; | |
661 static const char* gNY[] = {"NO", "YES"}; | |
662 r.appendf("MIP Map Support : %s\n", gNY[fMipMapSupport]); | |
663 r.appendf("NPOT Texture Tile Support : %s\n", gNY[fNPOTTextureTileS
upport]); | |
664 r.appendf("Two Sided Stencil Support : %s\n", gNY[fTwoSidedStencilS
upport]); | |
665 r.appendf("Stencil Wrap Ops Support : %s\n", gNY[fStencilWrapOpsSu
pport]); | |
666 r.appendf("Discard Render Target Support : %s\n", gNY[fDiscardRenderTar
getSupport]); | |
667 r.appendf("Reuse Scratch Textures : %s\n", gNY[fReuseScratchText
ures]); | |
668 r.appendf("Gpu Tracing Support : %s\n", gNY[fGpuTracingSuppor
t]); | |
669 r.appendf("Compressed Update Support : %s\n", gNY[fCompressedTexSub
ImageSupport]); | |
670 r.appendf("Oversized Stencil Support : %s\n", gNY[fOversizedStencil
Support]); | |
671 r.appendf("Texture Barrier Support : %s\n", gNY[fTextureBarrierSu
pport]); | |
672 r.appendf("Draw Instead of Clear [workaround] : %s\n", gNY[fUseDrawInsteadOf
Clear]); | |
673 | |
674 r.appendf("Max Texture Size : %d\n", fMaxTextureSize); | |
675 r.appendf("Max Render Target Size : %d\n", fMaxRenderTargetSize)
; | |
676 r.appendf("Max Sample Count : %d\n", fMaxSampleCount); | |
677 | |
678 static const char* kBlendEquationSupportNames[] = { | |
679 "Basic", | |
680 "Advanced", | |
681 "Advanced Coherent", | |
682 }; | |
683 GR_STATIC_ASSERT(0 == kBasic_BlendEquationSupport); | |
684 GR_STATIC_ASSERT(1 == kAdvanced_BlendEquationSupport); | |
685 GR_STATIC_ASSERT(2 == kAdvancedCoherent_BlendEquationSupport); | |
686 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kBlendEquationSupportNames) == kLast_BlendEq
uationSupport + 1); | |
687 | |
688 r.appendf("Blend Equation Support : %s\n", | |
689 kBlendEquationSupportNames[fBlendEquationSupport]); | |
690 r.appendf("Map Buffer Support : %s\n", | |
691 map_flags_to_string(fMapBufferFlags).c_str()); | |
692 | |
693 static const char* kConfigNames[] = { | |
694 "Unknown", // kUnknown_GrPixelConfig | |
695 "Alpha8", // kAlpha_8_GrPixelConfig, | |
696 "Index8", // kIndex_8_GrPixelConfig, | |
697 "RGB565", // kRGB_565_GrPixelConfig, | |
698 "RGBA444", // kRGBA_4444_GrPixelConfig, | |
699 "RGBA8888", // kRGBA_8888_GrPixelConfig, | |
700 "BGRA8888", // kBGRA_8888_GrPixelConfig, | |
701 "SRGBA8888",// kSRGBA_8888_GrPixelConfig, | |
702 "ETC1", // kETC1_GrPixelConfig, | |
703 "LATC", // kLATC_GrPixelConfig, | |
704 "R11EAC", // kR11_EAC_GrPixelConfig, | |
705 "ASTC12x12",// kASTC_12x12_GrPixelConfig, | |
706 "RGBAFloat",// kRGBA_float_GrPixelConfig | |
707 "AlphaHalf",// kAlpha_half_GrPixelConfig | |
708 "RGBAHalf", // kRGBA_half_GrPixelConfig | |
709 }; | |
710 GR_STATIC_ASSERT(0 == kUnknown_GrPixelConfig); | |
711 GR_STATIC_ASSERT(1 == kAlpha_8_GrPixelConfig); | |
712 GR_STATIC_ASSERT(2 == kIndex_8_GrPixelConfig); | |
713 GR_STATIC_ASSERT(3 == kRGB_565_GrPixelConfig); | |
714 GR_STATIC_ASSERT(4 == kRGBA_4444_GrPixelConfig); | |
715 GR_STATIC_ASSERT(5 == kRGBA_8888_GrPixelConfig); | |
716 GR_STATIC_ASSERT(6 == kBGRA_8888_GrPixelConfig); | |
717 GR_STATIC_ASSERT(7 == kSRGBA_8888_GrPixelConfig); | |
718 GR_STATIC_ASSERT(8 == kETC1_GrPixelConfig); | |
719 GR_STATIC_ASSERT(9 == kLATC_GrPixelConfig); | |
720 GR_STATIC_ASSERT(10 == kR11_EAC_GrPixelConfig); | |
721 GR_STATIC_ASSERT(11 == kASTC_12x12_GrPixelConfig); | |
722 GR_STATIC_ASSERT(12 == kRGBA_float_GrPixelConfig); | |
723 GR_STATIC_ASSERT(13 == kAlpha_half_GrPixelConfig); | |
724 GR_STATIC_ASSERT(14 == kRGBA_half_GrPixelConfig); | |
725 GR_STATIC_ASSERT(SK_ARRAY_COUNT(kConfigNames) == kGrPixelConfigCnt); | |
726 | |
727 SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][0]); | |
728 SkASSERT(!fConfigRenderSupport[kUnknown_GrPixelConfig][1]); | |
729 | |
730 for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) { | |
731 r.appendf("%s is renderable: %s, with MSAA: %s\n", | |
732 kConfigNames[i], | |
733 gNY[fConfigRenderSupport[i][0]], | |
734 gNY[fConfigRenderSupport[i][1]]); | |
735 } | |
736 | |
737 SkASSERT(!fConfigTextureSupport[kUnknown_GrPixelConfig]); | |
738 | |
739 for (size_t i = 1; i < SK_ARRAY_COUNT(kConfigNames); ++i) { | |
740 r.appendf("%s is uploadable to a texture: %s\n", | |
741 kConfigNames[i], | |
742 gNY[fConfigTextureSupport[i]]); | |
743 } | |
744 | |
745 return r; | |
746 } | |
747 | |
748 ////////////////////////////////////////////////////////////////////////////////
/////////////////// | |
749 | |
750 bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder, | 544 bool GrClipTarget::setupClip(GrPipelineBuilder* pipelineBuilder, |
751 GrPipelineBuilder::AutoRestoreFragmentProcessors* a
rfp, | 545 GrPipelineBuilder::AutoRestoreFragmentProcessors* a
rfp, |
752 GrPipelineBuilder::AutoRestoreStencil* ars, | 546 GrPipelineBuilder::AutoRestoreStencil* ars, |
753 GrScissorState* scissorState, | 547 GrScissorState* scissorState, |
754 const SkRect* devBounds) { | 548 const SkRect* devBounds) { |
755 return fClipMaskManager.setupClipping(pipelineBuilder, | 549 return fClipMaskManager.setupClipping(pipelineBuilder, |
756 arfp, | 550 arfp, |
757 ars, | 551 ars, |
758 scissorState, | 552 scissorState, |
759 devBounds); | 553 devBounds); |
760 } | 554 } |
OLD | NEW |