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

Side by Side Diff: src/gpu/vk/GrVkImage.cpp

Issue 1782453004: Fix some issues for Linux Vulkan build (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 9 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
« no previous file with comments | « src/gpu/vk/GrVkGpu.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "GrVkImage.h" 9 #include "GrVkImage.h"
10 #include "GrVkMemory.h" 10 #include "GrVkMemory.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor yBarrier); 42 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor yBarrier);
43 43
44 fCurrentLayout = newLayout; 44 fCurrentLayout = newLayout;
45 } 45 }
46 46
47 const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu, 47 const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu,
48 const ImageDesc& imageDesc) { 48 const ImageDesc& imageDesc) {
49 VkImage image = 0; 49 VkImage image = 0;
50 VkDeviceMemory alloc; 50 VkDeviceMemory alloc;
51 51
52 VkResult err;
53
54 VkImageLayout initialLayout = (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTil ing) 52 VkImageLayout initialLayout = (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTil ing)
55 ? VK_IMAGE_LAYOUT_PREINITIALIZED 53 ? VK_IMAGE_LAYOUT_PREINITIALIZED
56 : VK_IMAGE_LAYOUT_UNDEFINED; 54 : VK_IMAGE_LAYOUT_UNDEFINED;
57 55
58 // Create Image 56 // Create Image
59 VkSampleCountFlagBits vkSamples; 57 VkSampleCountFlagBits vkSamples;
60 if (!GrSampleCountToVkSampleCount(imageDesc.fSamples, &vkSamples)) { 58 if (!GrSampleCountToVkSampleCount(imageDesc.fSamples, &vkSamples)) {
61 return nullptr; 59 return nullptr;
62 } 60 }
63 const VkImageCreateInfo imageCreateInfo = { 61 const VkImageCreateInfo imageCreateInfo = {
64 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType 62 VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO, // sType
65 NULL, // pNext 63 NULL, // pNext
66 0, // VkImageCreateFlags 64 0, // VkImageCreateFlags
67 imageDesc.fImageType, // VkImageType 65 imageDesc.fImageType, // VkImageType
68 imageDesc.fFormat, // VkFormat 66 imageDesc.fFormat, // VkFormat
69 { imageDesc.fWidth, imageDesc.fHeight, 1 }, // VkExtent3D 67 { imageDesc.fWidth, imageDesc.fHeight, 1 }, // VkExtent3D
70 imageDesc.fLevels, // mipLevels 68 imageDesc.fLevels, // mipLevels
71 1, // arrayLayers 69 1, // arrayLayers
72 vkSamples, // samples 70 vkSamples, // samples
73 imageDesc.fImageTiling, // VkImageTiling 71 imageDesc.fImageTiling, // VkImageTiling
74 imageDesc.fUsageFlags, // VkImageUsageFlags 72 imageDesc.fUsageFlags, // VkImageUsageFlags
75 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode 73 VK_SHARING_MODE_EXCLUSIVE, // VkSharingMode
76 0, // queueFamilyCount 74 0, // queueFamilyCount
77 0, // pQueueFamilyIndices 75 0, // pQueueFamilyIndices
78 initialLayout // initialLayout 76 initialLayout // initialLayout
79 }; 77 };
80 78
81 err = VK_CALL(gpu, CreateImage(gpu->device(), &imageCreateInfo, nullptr, &im age)); 79 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), CreateImage(gpu->device(), &imageCre ateInfo, nullptr, &image));
82 SkASSERT(!err);
83 80
84 if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, imageDesc.fMemProps, &a lloc)) { 81 if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, imageDesc.fMemProps, &a lloc)) {
85 VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr)); 82 VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr));
86 return nullptr; 83 return nullptr;
87 } 84 }
88 85
89 GrVkImage::Resource::Flags flags = 86 GrVkImage::Resource::Flags flags =
90 (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling) ? Resource::kLinearTi ling_Flag 87 (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling) ? Resource::kLinearTi ling_Flag
91 : Resource::kNo_Flags ; 88 : Resource::kNo_Flags ;
92 89
(...skipping 15 matching lines...) Expand all
108 void GrVkImage::abandonImage() { 105 void GrVkImage::abandonImage() {
109 if (fResource) { 106 if (fResource) {
110 fResource->unrefAndAbandon(); 107 fResource->unrefAndAbandon();
111 fResource = nullptr; 108 fResource = nullptr;
112 } 109 }
113 } 110 }
114 111
115 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const { 112 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const {
116 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr)); 113 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr));
117 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr)); 114 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr));
118 } 115 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkGpu.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698