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

Side by Side Diff: tools/viewer/sk_app/VulkanWindowContext.cpp

Issue 2165703002: Make sk_app::WindowContext directly create a SkSurface without an intermediate GrRenderTarget (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 5 months 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 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 "GrContext.h" 9 #include "GrContext.h"
10 #include "GrRenderTarget.h" 10 #include "GrRenderTarget.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 void VulkanWindowContext::createBuffers(VkFormat format) { 251 void VulkanWindowContext::createBuffers(VkFormat format) {
252 GrVkFormatToPixelConfig(format, &fPixelConfig); 252 GrVkFormatToPixelConfig(format, &fPixelConfig);
253 253
254 fGetSwapchainImagesKHR(fBackendContext->fDevice, fSwapchain, &fImageCount, n ullptr); 254 fGetSwapchainImagesKHR(fBackendContext->fDevice, fSwapchain, &fImageCount, n ullptr);
255 SkASSERT(fImageCount); 255 SkASSERT(fImageCount);
256 fImages = new VkImage[fImageCount]; 256 fImages = new VkImage[fImageCount];
257 fGetSwapchainImagesKHR(fBackendContext->fDevice, fSwapchain, &fImageCount, f Images); 257 fGetSwapchainImagesKHR(fBackendContext->fDevice, fSwapchain, &fImageCount, f Images);
258 258
259 // set up initial image layouts and create surfaces 259 // set up initial image layouts and create surfaces
260 fImageLayouts = new VkImageLayout[fImageCount]; 260 fImageLayouts = new VkImageLayout[fImageCount];
261 fRenderTargets = new sk_sp<GrRenderTarget>[fImageCount]; 261 fRenderTargets = new sk_sp<GrRenderTarget>[fImageCount];
jvanverth1 2016/07/19 20:19:50 A little late to the party, but it looks like fRen
bsalomon 2016/07/19 20:38:37 Oh duh! Will fix.
262 fSurfaces = new sk_sp<SkSurface>[fImageCount]; 262 fSurfaces = new sk_sp<SkSurface>[fImageCount];
263 for (uint32_t i = 0; i < fImageCount; ++i) { 263 for (uint32_t i = 0; i < fImageCount; ++i) {
264 fImageLayouts[i] = VK_IMAGE_LAYOUT_UNDEFINED; 264 fImageLayouts[i] = VK_IMAGE_LAYOUT_UNDEFINED;
265 265
266 GrBackendRenderTargetDesc desc; 266 GrBackendRenderTargetDesc desc;
267 GrVkImageInfo info; 267 GrVkImageInfo info;
268 info.fImage = fImages[i]; 268 info.fImage = fImages[i];
269 info.fAlloc = { VK_NULL_HANDLE, 0, 0 }; 269 info.fAlloc = { VK_NULL_HANDLE, 0, 0 };
270 info.fImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; 270 info.fImageLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
271 info.fImageTiling = VK_IMAGE_TILING_OPTIMAL; 271 info.fImageTiling = VK_IMAGE_TILING_OPTIMAL;
272 info.fFormat = format; 272 info.fFormat = format;
273 info.fLevelCount = 1; 273 info.fLevelCount = 1;
274 desc.fWidth = fWidth; 274 desc.fWidth = fWidth;
275 desc.fHeight = fHeight; 275 desc.fHeight = fHeight;
276 desc.fConfig = fPixelConfig; 276 desc.fConfig = fPixelConfig;
277 desc.fOrigin = kTopLeft_GrSurfaceOrigin; 277 desc.fOrigin = kTopLeft_GrSurfaceOrigin;
278 desc.fSampleCnt = 0; 278 desc.fSampleCnt = 0;
279 desc.fStencilBits = 0; 279 desc.fStencilBits = 0;
280 desc.fRenderTargetHandle = (GrBackendObject) &info; 280 desc.fRenderTargetHandle = (GrBackendObject) &info;
281 fRenderTargets[i].reset(fContext->textureProvider()->wrapBackendRenderTa rget(desc));
282 281
283 fSurfaces[i] = this->createRenderSurface(fRenderTargets[i], 24); 282 fSurfaces[i] = this->createRenderSurface(desc, 24);
284 } 283 }
285 284
286 // create the command pool for the command buffers 285 // create the command pool for the command buffers
287 if (VK_NULL_HANDLE == fCommandPool) { 286 if (VK_NULL_HANDLE == fCommandPool) {
288 VkCommandPoolCreateInfo commandPoolInfo; 287 VkCommandPoolCreateInfo commandPoolInfo;
289 memset(&commandPoolInfo, 0, sizeof(VkCommandPoolCreateInfo)); 288 memset(&commandPoolInfo, 0, sizeof(VkCommandPoolCreateInfo));
290 commandPoolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; 289 commandPoolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
291 // this needs to be on the render queue 290 // this needs to be on the render queue
292 commandPoolInfo.queueFamilyIndex = fBackendContext->fGraphicsQueueIndex; 291 commandPoolInfo.queueFamilyIndex = fBackendContext->fGraphicsQueueIndex;
293 commandPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; 292 commandPoolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 &fSwapchain, // pSwapchains 594 &fSwapchain, // pSwapchains
596 &backbuffer->fImageIndex, // pImageIndices 595 &backbuffer->fImageIndex, // pImageIndices
597 NULL // pResults 596 NULL // pResults
598 }; 597 };
599 598
600 fQueuePresentKHR(fPresentQueue, &presentInfo); 599 fQueuePresentKHR(fPresentQueue, &presentInfo);
601 600
602 } 601 }
603 602
604 } //namespace sk_app 603 } //namespace sk_app
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698