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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 static void test_stencil_buffers(skiatest::Reporter* reporter, GrContext* contex
t) { | 72 static void test_stencil_buffers(skiatest::Reporter* reporter, GrContext* contex
t) { |
73 GrSurfaceDesc smallDesc; | 73 GrSurfaceDesc smallDesc; |
74 smallDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 74 smallDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
75 smallDesc.fConfig = kSkia8888_GrPixelConfig; | 75 smallDesc.fConfig = kSkia8888_GrPixelConfig; |
76 smallDesc.fWidth = 4; | 76 smallDesc.fWidth = 4; |
77 smallDesc.fHeight = 4; | 77 smallDesc.fHeight = 4; |
78 smallDesc.fSampleCnt = 0; | 78 smallDesc.fSampleCnt = 0; |
79 | 79 |
80 GrTextureProvider* cache = context->textureProvider(); | 80 GrTextureProvider* cache = context->textureProvider(); |
| 81 GrResourceProvider* resourceProvider = context->resourceProvider(); |
81 // Test that two budgeted RTs with the same desc share a stencil buffer. | 82 // Test that two budgeted RTs with the same desc share a stencil buffer. |
82 SkAutoTUnref<GrTexture> smallRT0(cache->createTexture(smallDesc, true)); | 83 SkAutoTUnref<GrTexture> smallRT0(cache->createTexture(smallDesc, true)); |
83 if (smallRT0 && smallRT0->asRenderTarget()) { | 84 if (smallRT0 && smallRT0->asRenderTarget()) { |
84 smallRT0->asRenderTarget()->renderTargetPriv().attachStencilAttachment()
; | 85 resourceProvider->attachStencilAttachment(smallRT0->asRenderTarget()); |
85 } | 86 } |
86 | 87 |
87 SkAutoTUnref<GrTexture> smallRT1(cache->createTexture(smallDesc, true)); | 88 SkAutoTUnref<GrTexture> smallRT1(cache->createTexture(smallDesc, true)); |
88 if (smallRT1 && smallRT1->asRenderTarget()) { | 89 if (smallRT1 && smallRT1->asRenderTarget()) { |
89 smallRT1->asRenderTarget()->renderTargetPriv().attachStencilAttachment()
; | 90 resourceProvider->attachStencilAttachment(smallRT1->asRenderTarget()); |
90 } | 91 } |
91 | 92 |
92 REPORTER_ASSERT(reporter, | 93 REPORTER_ASSERT(reporter, |
93 smallRT0 && smallRT1 && | 94 smallRT0 && smallRT1 && |
94 smallRT0->asRenderTarget() && smallRT1->asRenderTarget() && | 95 smallRT0->asRenderTarget() && smallRT1->asRenderTarget() && |
95 smallRT0->asRenderTarget()->renderTargetPriv().getStencilAtt
achment() == | 96 resourceProvider->attachStencilAttachment(smallRT0->asRender
Target()) == |
96 smallRT1->asRenderTarget()->renderTargetPriv().getStencilAtt
achment()); | 97 resourceProvider->attachStencilAttachment(smallRT1->asRender
Target())); |
97 | 98 |
98 // An unbudgeted RT with the same desc should also share. | 99 // An unbudgeted RT with the same desc should also share. |
99 SkAutoTUnref<GrTexture> smallRT2(cache->createTexture(smallDesc, false)); | 100 SkAutoTUnref<GrTexture> smallRT2(cache->createTexture(smallDesc, false)); |
100 if (smallRT2 && smallRT2->asRenderTarget()) { | 101 if (smallRT2 && smallRT2->asRenderTarget()) { |
101 smallRT2->asRenderTarget()->renderTargetPriv().attachStencilAttachment()
; | 102 resourceProvider->attachStencilAttachment(smallRT2->asRenderTarget()); |
102 } | 103 } |
103 REPORTER_ASSERT(reporter, | 104 REPORTER_ASSERT(reporter, |
104 smallRT0 && smallRT2 && | 105 smallRT0 && smallRT2 && |
105 smallRT0->asRenderTarget() && smallRT2->asRenderTarget() && | 106 smallRT0->asRenderTarget() && smallRT2->asRenderTarget() && |
106 smallRT0->asRenderTarget()->renderTargetPriv().getStencilAtt
achment() == | 107 resourceProvider->attachStencilAttachment(smallRT0->asRender
Target()) == |
107 smallRT2->asRenderTarget()->renderTargetPriv().getStencilAtt
achment()); | 108 resourceProvider->attachStencilAttachment(smallRT2->asRender
Target())); |
108 | 109 |
109 // An RT with a much larger size should not share. | 110 // An RT with a much larger size should not share. |
110 GrSurfaceDesc bigDesc; | 111 GrSurfaceDesc bigDesc; |
111 bigDesc.fFlags = kRenderTarget_GrSurfaceFlag; | 112 bigDesc.fFlags = kRenderTarget_GrSurfaceFlag; |
112 bigDesc.fConfig = kSkia8888_GrPixelConfig; | 113 bigDesc.fConfig = kSkia8888_GrPixelConfig; |
113 bigDesc.fWidth = 400; | 114 bigDesc.fWidth = 400; |
114 bigDesc.fHeight = 200; | 115 bigDesc.fHeight = 200; |
115 bigDesc.fSampleCnt = 0; | 116 bigDesc.fSampleCnt = 0; |
116 SkAutoTUnref<GrTexture> bigRT(cache->createTexture(bigDesc, false)); | 117 SkAutoTUnref<GrTexture> bigRT(cache->createTexture(bigDesc, false)); |
117 if (bigRT && bigRT->asRenderTarget()) { | 118 if (bigRT && bigRT->asRenderTarget()) { |
118 bigRT->asRenderTarget()->renderTargetPriv().attachStencilAttachment(); | 119 resourceProvider->attachStencilAttachment(bigRT->asRenderTarget()); |
119 } | 120 } |
120 REPORTER_ASSERT(reporter, | 121 REPORTER_ASSERT(reporter, |
121 smallRT0 && bigRT && | 122 smallRT0 && bigRT && |
122 smallRT0->asRenderTarget() && bigRT->asRenderTarget() && | 123 smallRT0->asRenderTarget() && bigRT->asRenderTarget() && |
123 smallRT0->asRenderTarget()->renderTargetPriv().getStencilAtt
achment() != | 124 resourceProvider->attachStencilAttachment(smallRT0->asRender
Target()) != |
124 bigRT->asRenderTarget()->renderTargetPriv().getStencilAttach
ment()); | 125 resourceProvider->attachStencilAttachment(bigRT->asRenderTar
get())); |
125 | 126 |
126 if (context->caps()->maxSampleCount() >= 4) { | 127 if (context->caps()->maxSampleCount() >= 4) { |
127 // An RT with a different sample count should not share. | 128 // An RT with a different sample count should not share. |
128 GrSurfaceDesc smallMSAADesc = smallDesc; | 129 GrSurfaceDesc smallMSAADesc = smallDesc; |
129 smallMSAADesc.fSampleCnt = 4; | 130 smallMSAADesc.fSampleCnt = 4; |
130 SkAutoTUnref<GrTexture> smallMSAART0(cache->createTexture(smallMSAADesc,
false)); | 131 SkAutoTUnref<GrTexture> smallMSAART0(cache->createTexture(smallMSAADesc,
false)); |
131 if (smallMSAART0 && smallMSAART0->asRenderTarget()) { | 132 if (smallMSAART0 && smallMSAART0->asRenderTarget()) { |
132 smallMSAART0->asRenderTarget()->renderTargetPriv().attachStencilAtta
chment(); | 133 resourceProvider->attachStencilAttachment(smallMSAART0->asRenderTarg
et()); |
133 } | 134 } |
134 #ifdef SK_BUILD_FOR_ANDROID | 135 #ifdef SK_BUILD_FOR_ANDROID |
135 if (!smallMSAART0) { | 136 if (!smallMSAART0) { |
136 // The nexus player seems to fail to create MSAA textures. | 137 // The nexus player seems to fail to create MSAA textures. |
137 return; | 138 return; |
138 } | 139 } |
139 #endif | 140 #endif |
140 REPORTER_ASSERT(reporter, | 141 REPORTER_ASSERT(reporter, |
141 smallRT0 && smallMSAART0 && | 142 smallRT0 && smallMSAART0 && |
142 smallRT0->asRenderTarget() && smallMSAART0->asRenderTarg
et() && | 143 smallRT0->asRenderTarget() && smallMSAART0->asRenderTarg
et() && |
143 smallRT0->asRenderTarget()->renderTargetPriv().getStenci
lAttachment() != | 144 resourceProvider->attachStencilAttachment(smallRT0->asRe
nderTarget()) != |
144 smallMSAART0->asRenderTarget()->renderTargetPriv().getSt
encilAttachment()); | 145 resourceProvider->attachStencilAttachment(smallMSAART0->
asRenderTarget())); |
145 // A second MSAA RT should share with the first MSAA RT. | 146 // A second MSAA RT should share with the first MSAA RT. |
146 SkAutoTUnref<GrTexture> smallMSAART1(cache->createTexture(smallMSAADesc,
false)); | 147 SkAutoTUnref<GrTexture> smallMSAART1(cache->createTexture(smallMSAADesc,
false)); |
147 if (smallMSAART1 && smallMSAART1->asRenderTarget()) { | 148 if (smallMSAART1 && smallMSAART1->asRenderTarget()) { |
148 smallMSAART1->asRenderTarget()->renderTargetPriv().attachStencilAtta
chment(); | 149 resourceProvider->attachStencilAttachment(smallMSAART1->asRenderTarg
et()); |
149 } | 150 } |
150 REPORTER_ASSERT(reporter, | 151 REPORTER_ASSERT(reporter, |
151 smallMSAART0 && smallMSAART1 && | 152 smallMSAART0 && smallMSAART1 && |
152 smallMSAART0->asRenderTarget() && | 153 smallMSAART0->asRenderTarget() && |
153 smallMSAART1->asRenderTarget() && | 154 smallMSAART1->asRenderTarget() && |
154 smallMSAART0->asRenderTarget()->renderTargetPriv().getSt
encilAttachment() == | 155 resourceProvider->attachStencilAttachment(smallMSAART0->
asRenderTarget()) == |
155 smallMSAART1->asRenderTarget()->renderTargetPriv().getSt
encilAttachment()); | 156 resourceProvider->attachStencilAttachment(smallMSAART1->
asRenderTarget())); |
156 // But not one with a larger sample count should not. (Also check that t
he request for 4 | 157 // But not one with a larger sample count should not. (Also check that t
he request for 4 |
157 // samples didn't get rounded up to >= 8 or else they could share.). | 158 // samples didn't get rounded up to >= 8 or else they could share.). |
158 if (context->caps()->maxSampleCount() >= 8 && | 159 if (context->caps()->maxSampleCount() >= 8 && |
159 smallMSAART0 && smallMSAART0->asRenderTarget() && | 160 smallMSAART0 && smallMSAART0->asRenderTarget() && |
160 smallMSAART0->asRenderTarget()->numColorSamples() < 8) { | 161 smallMSAART0->asRenderTarget()->numColorSamples() < 8) { |
161 smallMSAADesc.fSampleCnt = 8; | 162 smallMSAADesc.fSampleCnt = 8; |
162 smallMSAART1.reset(cache->createTexture(smallMSAADesc, false)); | 163 smallMSAART1.reset(cache->createTexture(smallMSAADesc, false)); |
163 SkAutoTUnref<GrTexture> smallMSAART1(cache->createTexture(smallMSAAD
esc, false)); | 164 SkAutoTUnref<GrTexture> smallMSAART1(cache->createTexture(smallMSAAD
esc, false)); |
164 if (smallMSAART1 && smallMSAART1->asRenderTarget()) { | 165 if (smallMSAART1 && smallMSAART1->asRenderTarget()) { |
165 smallMSAART1->asRenderTarget()->renderTargetPriv().attachStencil
Attachment(); | 166 resourceProvider->attachStencilAttachment(smallMSAART1->asRender
Target()); |
166 } | 167 } |
167 REPORTER_ASSERT(reporter, | 168 REPORTER_ASSERT(reporter, |
168 smallMSAART0 && smallMSAART1 && | 169 smallMSAART0 && smallMSAART1 && |
169 smallMSAART0->asRenderTarget() && | 170 smallMSAART0->asRenderTarget() && |
170 smallMSAART1->asRenderTarget() && | 171 smallMSAART1->asRenderTarget() && |
171 smallMSAART0->asRenderTarget()->renderTargetPriv().getSt
encilAttachment() != | 172 resourceProvider->attachStencilAttachment(smallMSAART0->
asRenderTarget()) != |
172 smallMSAART1->asRenderTarget()->renderTargetPriv().getSt
encilAttachment()); | 173 resourceProvider->attachStencilAttachment(smallMSAART1->
asRenderTarget())); |
173 } | 174 } |
174 } | 175 } |
175 } | 176 } |
176 | 177 |
177 static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* cont
ext) { | 178 static void test_wrapped_resources(skiatest::Reporter* reporter, GrContext* cont
ext) { |
178 const GrGpu* gpu = context->getGpu(); | 179 const GrGpu* gpu = context->getGpu(); |
179 // this test is only valid for GL | 180 // this test is only valid for GL |
180 if (!gpu || !gpu->glContextForTesting()) { | 181 if (!gpu || !gpu->glContextForTesting()) { |
181 return; | 182 return; |
182 } | 183 } |
(...skipping 1102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 test_purge_invalidated(reporter); | 1286 test_purge_invalidated(reporter); |
1286 test_cache_chained_purge(reporter); | 1287 test_cache_chained_purge(reporter); |
1287 test_resource_size_changed(reporter); | 1288 test_resource_size_changed(reporter); |
1288 test_timestamp_wrap(reporter); | 1289 test_timestamp_wrap(reporter); |
1289 test_flush(reporter); | 1290 test_flush(reporter); |
1290 test_large_resource_count(reporter); | 1291 test_large_resource_count(reporter); |
1291 test_custom_data(reporter); | 1292 test_custom_data(reporter); |
1292 } | 1293 } |
1293 | 1294 |
1294 #endif | 1295 #endif |
OLD | NEW |