OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 "GrVkGpu.h" | 8 #include "GrVkGpu.h" |
9 | 9 |
10 #include "GrContextOptions.h" | 10 #include "GrContextOptions.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 , fQueue(queue) | 173 , fQueue(queue) |
174 , fCmdPool(cmdPool) | 174 , fCmdPool(cmdPool) |
175 , fResourceProvider(this) | 175 , fResourceProvider(this) |
176 , fVkInstance(inst) { | 176 , fVkInstance(inst) { |
177 fInterface.reset(GrVkCreateInterface(fVkInstance)); | 177 fInterface.reset(GrVkCreateInterface(fVkInstance)); |
178 fCompiler = shaderc_compiler_initialize(); | 178 fCompiler = shaderc_compiler_initialize(); |
179 | 179 |
180 fVkCaps.reset(new GrVkCaps(options, fInterface, physDev)); | 180 fVkCaps.reset(new GrVkCaps(options, fInterface, physDev)); |
181 fCaps.reset(SkRef(fVkCaps.get())); | 181 fCaps.reset(SkRef(fVkCaps.get())); |
182 | 182 |
| 183 fResourceProvider.init(); |
| 184 |
183 fCurrentCmdBuffer = fResourceProvider.createCommandBuffer(); | 185 fCurrentCmdBuffer = fResourceProvider.createCommandBuffer(); |
184 SkASSERT(fCurrentCmdBuffer); | 186 SkASSERT(fCurrentCmdBuffer); |
185 fCurrentCmdBuffer->begin(this); | 187 fCurrentCmdBuffer->begin(this); |
186 VK_CALL(GetPhysicalDeviceMemoryProperties(physDev, &fPhysDevMemProps)); | 188 VK_CALL(GetPhysicalDeviceMemoryProperties(physDev, &fPhysDevMemProps)); |
187 | 189 |
188 } | 190 } |
189 | 191 |
190 GrVkGpu::~GrVkGpu() { | 192 GrVkGpu::~GrVkGpu() { |
191 shaderc_compiler_release(fCompiler); | 193 shaderc_compiler_release(fCompiler); |
192 fCurrentCmdBuffer->end(this); | 194 fCurrentCmdBuffer->end(this); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 bool GrVkGpu::onWritePixels(GrSurface* surface, | 262 bool GrVkGpu::onWritePixels(GrSurface* surface, |
261 int left, int top, int width, int height, | 263 int left, int top, int width, int height, |
262 GrPixelConfig config, | 264 GrPixelConfig config, |
263 const SkTArray<GrMipLevel>& texels) { | 265 const SkTArray<GrMipLevel>& texels) { |
264 GrVkTexture* vkTex = static_cast<GrVkTexture*>(surface->asTexture()); | 266 GrVkTexture* vkTex = static_cast<GrVkTexture*>(surface->asTexture()); |
265 if (!vkTex) { | 267 if (!vkTex) { |
266 return false; | 268 return false; |
267 } | 269 } |
268 | 270 |
269 // TODO: We're ignoring MIP levels here. | 271 // TODO: We're ignoring MIP levels here. |
| 272 if (texels.empty() || !texels.begin()->fPixels) { |
| 273 return false; |
| 274 } |
270 | 275 |
271 // We assume Vulkan doesn't do sRGB <-> linear conversions when reading and
writing pixels. | 276 // We assume Vulkan doesn't do sRGB <-> linear conversions when reading and
writing pixels. |
272 if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) { | 277 if (GrPixelConfigIsSRGB(surface->config()) != GrPixelConfigIsSRGB(config)) { |
273 return false; | 278 return false; |
274 } | 279 } |
275 | 280 |
276 bool success = false; | 281 bool success = false; |
277 if (GrPixelConfigIsCompressed(vkTex->desc().fConfig)) { | 282 if (GrPixelConfigIsCompressed(vkTex->desc().fConfig)) { |
278 // We check that config == desc.fConfig in GrGpu::getWritePixelsInfo() | 283 // We check that config == desc.fConfig in GrGpu::getWritePixelsInfo() |
279 SkASSERT(config == vkTex->desc().fConfig); | 284 SkASSERT(config == vkTex->desc().fConfig); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
530 #endif | 535 #endif |
531 } else { | 536 } else { |
532 tex = GrVkTexture::CreateNewTexture(this, desc, lifeCycle, imageDesc); | 537 tex = GrVkTexture::CreateNewTexture(this, desc, lifeCycle, imageDesc); |
533 } | 538 } |
534 | 539 |
535 if (!tex) { | 540 if (!tex) { |
536 return nullptr; | 541 return nullptr; |
537 } | 542 } |
538 | 543 |
539 // TODO: We're ignoring MIP levels here. | 544 // TODO: We're ignoring MIP levels here. |
540 if (!texels.empty()) { | 545 if (!texels.empty() && texels.begin()->fPixels) { |
541 if (!this->uploadTexData(tex, 0, 0, desc.fWidth, desc.fHeight, desc.fCon
fig, | 546 if (!this->uploadTexData(tex, 0, 0, desc.fWidth, desc.fHeight, desc.fCon
fig, |
542 texels.begin()->fPixels, texels.begin()->fRowBy
tes)) { | 547 texels.begin()->fPixels, texels.begin()->fRowBy
tes)) { |
543 tex->unref(); | 548 tex->unref(); |
544 return nullptr; | 549 return nullptr; |
545 } | 550 } |
546 } | 551 } |
547 | 552 |
548 return tex; | 553 return tex; |
549 } | 554 } |
550 | 555 |
(...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1405 int set_a_break_pt_here = 9; | 1410 int set_a_break_pt_here = 9; |
1406 aglSwapBuffers(aglGetCurrentContext()); | 1411 aglSwapBuffers(aglGetCurrentContext()); |
1407 #elif defined(SK_BUILD_FOR_WIN32) | 1412 #elif defined(SK_BUILD_FOR_WIN32) |
1408 SwapBuf(); | 1413 SwapBuf(); |
1409 int set_a_break_pt_here = 9; | 1414 int set_a_break_pt_here = 9; |
1410 SwapBuf(); | 1415 SwapBuf(); |
1411 #endif | 1416 #endif |
1412 #endif | 1417 #endif |
1413 } | 1418 } |
1414 | 1419 |
OLD | NEW |