OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 // Include here to ensure SK_SUPPORT_GPU is set correctly before it is examined. | 8 // Include here to ensure SK_SUPPORT_GPU is set correctly before it is examined. |
9 #include "SkTypes.h" | 9 #include "SkTypes.h" |
10 | 10 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 static void test_stencil_buffers(skiatest::Reporter* reporter, GrContext* contex
t) { | 71 static void test_stencil_buffers(skiatest::Reporter* reporter, GrContext* contex
t) { |
72 GrSurfaceDesc smallDesc; | 72 GrSurfaceDesc smallDesc; |
73 smallDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 73 smallDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
74 smallDesc.fConfig = kSkia8888_GrPixelConfig; | 74 smallDesc.fConfig = kSkia8888_GrPixelConfig; |
75 smallDesc.fWidth = 4; | 75 smallDesc.fWidth = 4; |
76 smallDesc.fHeight = 4; | 76 smallDesc.fHeight = 4; |
77 smallDesc.fSampleCnt = 0; | 77 smallDesc.fSampleCnt = 0; |
78 | 78 |
| 79 GrTextureProvider* cache = context->textureProvider(); |
79 // Test that two budgeted RTs with the same desc share a stencil buffer. | 80 // Test that two budgeted RTs with the same desc share a stencil buffer. |
80 SkAutoTUnref<GrTexture> smallRT0(context->createTexture(smallDesc, true)); | 81 SkAutoTUnref<GrTexture> smallRT0(cache->createTexture(smallDesc, true)); |
81 if (smallRT0 && smallRT0->asRenderTarget()) { | 82 if (smallRT0 && smallRT0->asRenderTarget()) { |
82 smallRT0->asRenderTarget()->renderTargetPriv().attachStencilAttachment()
; | 83 smallRT0->asRenderTarget()->renderTargetPriv().attachStencilAttachment()
; |
83 } | 84 } |
84 | 85 |
85 SkAutoTUnref<GrTexture> smallRT1(context->createTexture(smallDesc, true)); | 86 SkAutoTUnref<GrTexture> smallRT1(cache->createTexture(smallDesc, true)); |
86 if (smallRT1 && smallRT1->asRenderTarget()) { | 87 if (smallRT1 && smallRT1->asRenderTarget()) { |
87 smallRT1->asRenderTarget()->renderTargetPriv().attachStencilAttachment()
; | 88 smallRT1->asRenderTarget()->renderTargetPriv().attachStencilAttachment()
; |
88 } | 89 } |
89 | 90 |
90 REPORTER_ASSERT(reporter, | 91 REPORTER_ASSERT(reporter, |
91 smallRT0 && smallRT1 && | 92 smallRT0 && smallRT1 && |
92 smallRT0->asRenderTarget() && smallRT1->asRenderTarget() && | 93 smallRT0->asRenderTarget() && smallRT1->asRenderTarget() && |
93 smallRT0->asRenderTarget()->renderTargetPriv().getStencilAtt
achment() == | 94 smallRT0->asRenderTarget()->renderTargetPriv().getStencilAtt
achment() == |
94 smallRT1->asRenderTarget()->renderTargetPriv().getStencilAtt
achment()); | 95 smallRT1->asRenderTarget()->renderTargetPriv().getStencilAtt
achment()); |
95 | 96 |
96 // An unbudgeted RT with the same desc should also share. | 97 // An unbudgeted RT with the same desc should also share. |
97 SkAutoTUnref<GrTexture> smallRT2(context->createTexture(smallDesc, false)); | 98 SkAutoTUnref<GrTexture> smallRT2(cache->createTexture(smallDesc, false)); |
98 if (smallRT2 && smallRT2->asRenderTarget()) { | 99 if (smallRT2 && smallRT2->asRenderTarget()) { |
99 smallRT2->asRenderTarget()->renderTargetPriv().attachStencilAttachment()
; | 100 smallRT2->asRenderTarget()->renderTargetPriv().attachStencilAttachment()
; |
100 } | 101 } |
101 REPORTER_ASSERT(reporter, | 102 REPORTER_ASSERT(reporter, |
102 smallRT0 && smallRT2 && | 103 smallRT0 && smallRT2 && |
103 smallRT0->asRenderTarget() && smallRT2->asRenderTarget() && | 104 smallRT0->asRenderTarget() && smallRT2->asRenderTarget() && |
104 smallRT0->asRenderTarget()->renderTargetPriv().getStencilAtt
achment() == | 105 smallRT0->asRenderTarget()->renderTargetPriv().getStencilAtt
achment() == |
105 smallRT2->asRenderTarget()->renderTargetPriv().getStencilAtt
achment()); | 106 smallRT2->asRenderTarget()->renderTargetPriv().getStencilAtt
achment()); |
106 | 107 |
107 // An RT with a much larger size should not share. | 108 // An RT with a much larger size should not share. |
108 GrSurfaceDesc bigDesc; | 109 GrSurfaceDesc bigDesc; |
109 bigDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 110 bigDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
110 bigDesc.fConfig = kSkia8888_GrPixelConfig; | 111 bigDesc.fConfig = kSkia8888_GrPixelConfig; |
111 bigDesc.fWidth = 400; | 112 bigDesc.fWidth = 400; |
112 bigDesc.fHeight = 200; | 113 bigDesc.fHeight = 200; |
113 bigDesc.fSampleCnt = 0; | 114 bigDesc.fSampleCnt = 0; |
114 SkAutoTUnref<GrTexture> bigRT(context->createTexture(bigDesc, false)); | 115 SkAutoTUnref<GrTexture> bigRT(cache->createTexture(bigDesc, false)); |
115 if (bigRT && bigRT->asRenderTarget()) { | 116 if (bigRT && bigRT->asRenderTarget()) { |
116 bigRT->asRenderTarget()->renderTargetPriv().attachStencilAttachment(); | 117 bigRT->asRenderTarget()->renderTargetPriv().attachStencilAttachment(); |
117 } | 118 } |
118 REPORTER_ASSERT(reporter, | 119 REPORTER_ASSERT(reporter, |
119 smallRT0 && bigRT && | 120 smallRT0 && bigRT && |
120 smallRT0->asRenderTarget() && bigRT->asRenderTarget() && | 121 smallRT0->asRenderTarget() && bigRT->asRenderTarget() && |
121 smallRT0->asRenderTarget()->renderTargetPriv().getStencilAtt
achment() != | 122 smallRT0->asRenderTarget()->renderTargetPriv().getStencilAtt
achment() != |
122 bigRT->asRenderTarget()->renderTargetPriv().getStencilAttach
ment()); | 123 bigRT->asRenderTarget()->renderTargetPriv().getStencilAttach
ment()); |
123 | 124 |
124 if (context->getMaxSampleCount() >= 4) { | 125 if (context->getMaxSampleCount() >= 4) { |
125 // An RT with a different sample count should not share. | 126 // An RT with a different sample count should not share. |
126 GrSurfaceDesc smallMSAADesc = smallDesc; | 127 GrSurfaceDesc smallMSAADesc = smallDesc; |
127 smallMSAADesc.fSampleCnt = 4; | 128 smallMSAADesc.fSampleCnt = 4; |
128 SkAutoTUnref<GrTexture> smallMSAART0(context->createTexture(smallMSAADes
c, false)); | 129 SkAutoTUnref<GrTexture> smallMSAART0(cache->createTexture(smallMSAADesc,
false)); |
129 if (smallMSAART0 && smallMSAART0->asRenderTarget()) { | 130 if (smallMSAART0 && smallMSAART0->asRenderTarget()) { |
130 smallMSAART0->asRenderTarget()->renderTargetPriv().attachStencilAtta
chment(); | 131 smallMSAART0->asRenderTarget()->renderTargetPriv().attachStencilAtta
chment(); |
131 } | 132 } |
132 #ifdef SK_BUILD_FOR_ANDROID | 133 #ifdef SK_BUILD_FOR_ANDROID |
133 if (!smallMSAART0) { | 134 if (!smallMSAART0) { |
134 // The nexus player seems to fail to create MSAA textures. | 135 // The nexus player seems to fail to create MSAA textures. |
135 return; | 136 return; |
136 } | 137 } |
137 #endif | 138 #endif |
138 REPORTER_ASSERT(reporter, | 139 REPORTER_ASSERT(reporter, |
139 smallRT0 && smallMSAART0 && | 140 smallRT0 && smallMSAART0 && |
140 smallRT0->asRenderTarget() && smallMSAART0->asRenderTarg
et() && | 141 smallRT0->asRenderTarget() && smallMSAART0->asRenderTarg
et() && |
141 smallRT0->asRenderTarget()->renderTargetPriv().getStenci
lAttachment() != | 142 smallRT0->asRenderTarget()->renderTargetPriv().getStenci
lAttachment() != |
142 smallMSAART0->asRenderTarget()->renderTargetPriv().getSt
encilAttachment()); | 143 smallMSAART0->asRenderTarget()->renderTargetPriv().getSt
encilAttachment()); |
143 // A second MSAA RT should share with the first MSAA RT. | 144 // A second MSAA RT should share with the first MSAA RT. |
144 SkAutoTUnref<GrTexture> smallMSAART1(context->createTexture(smallMSAADes
c, false)); | 145 SkAutoTUnref<GrTexture> smallMSAART1(cache->createTexture(smallMSAADesc,
false)); |
145 if (smallMSAART1 && smallMSAART1->asRenderTarget()) { | 146 if (smallMSAART1 && smallMSAART1->asRenderTarget()) { |
146 smallMSAART1->asRenderTarget()->renderTargetPriv().attachStencilAtta
chment(); | 147 smallMSAART1->asRenderTarget()->renderTargetPriv().attachStencilAtta
chment(); |
147 } | 148 } |
148 REPORTER_ASSERT(reporter, | 149 REPORTER_ASSERT(reporter, |
149 smallMSAART0 && smallMSAART1 && | 150 smallMSAART0 && smallMSAART1 && |
150 smallMSAART0->asRenderTarget() && | 151 smallMSAART0->asRenderTarget() && |
151 smallMSAART1->asRenderTarget() && | 152 smallMSAART1->asRenderTarget() && |
152 smallMSAART0->asRenderTarget()->renderTargetPriv().getSt
encilAttachment() == | 153 smallMSAART0->asRenderTarget()->renderTargetPriv().getSt
encilAttachment() == |
153 smallMSAART1->asRenderTarget()->renderTargetPriv().getSt
encilAttachment()); | 154 smallMSAART1->asRenderTarget()->renderTargetPriv().getSt
encilAttachment()); |
154 // But not one with a larger sample count should not. (Also check that t
he request for 4 | 155 // But not one with a larger sample count should not. (Also check that t
he request for 4 |
155 // samples didn't get rounded up to >= 8 or else they could share.). | 156 // samples didn't get rounded up to >= 8 or else they could share.). |
156 if (context->getMaxSampleCount() >= 8 && smallMSAART0 && smallMSAART0->a
sRenderTarget() && | 157 if (context->getMaxSampleCount() >= 8 && smallMSAART0 && smallMSAART0->a
sRenderTarget() && |
157 smallMSAART0->asRenderTarget()->numSamples() < 8) { | 158 smallMSAART0->asRenderTarget()->numSamples() < 8) { |
158 smallMSAADesc.fSampleCnt = 8; | 159 smallMSAADesc.fSampleCnt = 8; |
159 smallMSAART1.reset(context->createTexture(smallMSAADesc, false)); | 160 smallMSAART1.reset(cache->createTexture(smallMSAADesc, false)); |
160 SkAutoTUnref<GrTexture> smallMSAART1(context->createTexture(smallMSA
ADesc, false)); | 161 SkAutoTUnref<GrTexture> smallMSAART1(cache->createTexture(smallMSAAD
esc, false)); |
161 if (smallMSAART1 && smallMSAART1->asRenderTarget()) { | 162 if (smallMSAART1 && smallMSAART1->asRenderTarget()) { |
162 smallMSAART1->asRenderTarget()->renderTargetPriv().attachStencil
Attachment(); | 163 smallMSAART1->asRenderTarget()->renderTargetPriv().attachStencil
Attachment(); |
163 } | 164 } |
164 REPORTER_ASSERT(reporter, | 165 REPORTER_ASSERT(reporter, |
165 smallMSAART0 && smallMSAART1 && | 166 smallMSAART0 && smallMSAART1 && |
166 smallMSAART0->asRenderTarget() && | 167 smallMSAART0->asRenderTarget() && |
167 smallMSAART1->asRenderTarget() && | 168 smallMSAART1->asRenderTarget() && |
168 smallMSAART0->asRenderTarget()->renderTargetPriv().getSt
encilAttachment() != | 169 smallMSAART0->asRenderTarget()->renderTargetPriv().getSt
encilAttachment() != |
169 smallMSAART1->asRenderTarget()->renderTargetPriv().getSt
encilAttachment()); | 170 smallMSAART1->asRenderTarget()->renderTargetPriv().getSt
encilAttachment()); |
170 } | 171 } |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1204 test_scratch_key_consistency(reporter); | 1205 test_scratch_key_consistency(reporter); |
1205 test_purge_invalidated(reporter); | 1206 test_purge_invalidated(reporter); |
1206 test_cache_chained_purge(reporter); | 1207 test_cache_chained_purge(reporter); |
1207 test_resource_size_changed(reporter); | 1208 test_resource_size_changed(reporter); |
1208 test_timestamp_wrap(reporter); | 1209 test_timestamp_wrap(reporter); |
1209 test_flush(reporter); | 1210 test_flush(reporter); |
1210 test_large_resource_count(reporter); | 1211 test_large_resource_count(reporter); |
1211 } | 1212 } |
1212 | 1213 |
1213 #endif | 1214 #endif |
OLD | NEW |