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

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

Issue 1906623002: Update min Vulkan version to 1.0.8.0, and fix various bugs (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 4 years, 8 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/GrVkImage.h ('k') | src/gpu/vk/GrVkPipelineState.h » ('j') | 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"
11 #include "GrVkUtil.h" 11 #include "GrVkUtil.h"
12 12
13 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X) 13 #define VK_CALL(GPU, X) GR_VK_CALL(GPU->vkInterface(), X)
14 14
15 VkImageAspectFlags vk_format_to_aspect_flags(VkFormat format) {
16 switch (format) {
17 case VK_FORMAT_S8_UINT:
18 return VK_IMAGE_ASPECT_STENCIL_BIT;
19 case VK_FORMAT_D24_UNORM_S8_UINT: // fallthrough
20 case VK_FORMAT_D32_SFLOAT_S8_UINT:
21 return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
22 default:
23 SkASSERT(GrVkFormatToPixelConfig(format, nullptr));
24 return VK_IMAGE_ASPECT_COLOR_BIT;
25 }
26 }
27
15 void GrVkImage::setImageLayout(const GrVkGpu* gpu, VkImageLayout newLayout, 28 void GrVkImage::setImageLayout(const GrVkGpu* gpu, VkImageLayout newLayout,
16 VkAccessFlags srcAccessMask, 29 VkAccessFlags srcAccessMask,
17 VkAccessFlags dstAccessMask, 30 VkAccessFlags dstAccessMask,
18 VkPipelineStageFlags srcStageMask, 31 VkPipelineStageFlags srcStageMask,
19 VkPipelineStageFlags dstStageMask, 32 VkPipelineStageFlags dstStageMask,
20 bool byRegion) { 33 bool byRegion) {
21 SkASSERT(VK_IMAGE_LAYOUT_GENERAL != newLayout || VK_IMAGE_LAYOUT_PREINITIALI ZED != newLayout); 34 SkASSERT(VK_IMAGE_LAYOUT_GENERAL != newLayout || VK_IMAGE_LAYOUT_PREINITIALI ZED != newLayout);
22 // Is this reasonable? Could someone want to keep the same layout but use th e masks to force 35 // Is this reasonable? Could someone want to keep the same layout but use th e masks to force
23 // a barrier on certain things? 36 // a barrier on certain things?
24 if (newLayout == fCurrentLayout) { 37 if (newLayout == fCurrentLayout) {
25 return; 38 return;
26 } 39 }
27 40 VkImageAspectFlags aspectFlags = vk_format_to_aspect_flags(fResource->fForma t);
28 VkImageMemoryBarrier imageMemoryBarrier = { 41 VkImageMemoryBarrier imageMemoryBarrier = {
29 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType 42 VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER, // sType
30 NULL, // pNext 43 NULL, // pNext
31 srcAccessMask, // outputMask 44 srcAccessMask, // outputMask
32 dstAccessMask, // inputMask 45 dstAccessMask, // inputMask
33 fCurrentLayout, // oldLayout 46 fCurrentLayout, // oldLayout
34 newLayout, // newLayout 47 newLayout, // newLayout
35 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex 48 VK_QUEUE_FAMILY_IGNORED, // srcQueueFamilyIndex
36 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex 49 VK_QUEUE_FAMILY_IGNORED, // dstQueueFamilyIndex
37 fResource->fImage, // image 50 fResource->fImage, // image
38 { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 } // subresourceRange 51 { aspectFlags, 0, 1, 0, 1 } // subresourceRange
39 }; 52 };
40 53
41 // TODO: restrict to area of image we're interested in 54 // TODO: restrict to area of image we're interested in
42 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor yBarrier); 55 gpu->addImageMemoryBarrier(srcStageMask, dstStageMask, byRegion, &imageMemor yBarrier);
43 56
44 fCurrentLayout = newLayout; 57 fCurrentLayout = newLayout;
45 } 58 }
46 59
47 const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu, 60 const GrVkImage::Resource* GrVkImage::CreateResource(const GrVkGpu* gpu,
48 const ImageDesc& imageDesc) { 61 const ImageDesc& imageDesc) {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 97
85 if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, imageDesc.fMemProps, &a lloc)) { 98 if (!GrVkMemory::AllocAndBindImageMemory(gpu, image, imageDesc.fMemProps, &a lloc)) {
86 VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr)); 99 VK_CALL(gpu, DestroyImage(gpu->device(), image, nullptr));
87 return nullptr; 100 return nullptr;
88 } 101 }
89 102
90 GrVkImage::Resource::Flags flags = 103 GrVkImage::Resource::Flags flags =
91 (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling) ? Resource::kLinearTi ling_Flag 104 (VK_IMAGE_TILING_LINEAR == imageDesc.fImageTiling) ? Resource::kLinearTi ling_Flag
92 : Resource::kNo_Flags ; 105 : Resource::kNo_Flags ;
93 106
94 return (new GrVkImage::Resource(image, alloc, flags)); 107 return (new GrVkImage::Resource(image, alloc, flags, imageDesc.fFormat));
95 } 108 }
96 109
97 GrVkImage::~GrVkImage() { 110 GrVkImage::~GrVkImage() {
98 // should have been released or abandoned first 111 // should have been released or abandoned first
99 SkASSERT(!fResource); 112 SkASSERT(!fResource);
100 } 113 }
101 114
102 void GrVkImage::releaseImage(const GrVkGpu* gpu) { 115 void GrVkImage::releaseImage(const GrVkGpu* gpu) {
103 if (fResource) { 116 if (fResource) {
104 fResource->unref(gpu); 117 fResource->unref(gpu);
105 fResource = nullptr; 118 fResource = nullptr;
106 } 119 }
107 } 120 }
108 121
109 void GrVkImage::abandonImage() { 122 void GrVkImage::abandonImage() {
110 if (fResource) { 123 if (fResource) {
111 fResource->unrefAndAbandon(); 124 fResource->unrefAndAbandon();
112 fResource = nullptr; 125 fResource = nullptr;
113 } 126 }
114 } 127 }
115 128
116 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const { 129 void GrVkImage::Resource::freeGPUData(const GrVkGpu* gpu) const {
117 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr)); 130 VK_CALL(gpu, DestroyImage(gpu->device(), fImage, nullptr));
118 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr)); 131 VK_CALL(gpu, FreeMemory(gpu->device(), fAlloc, nullptr));
119 } 132 }
120 133
121 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const { 134 void GrVkImage::BorrowedResource::freeGPUData(const GrVkGpu* gpu) const {
122 } 135 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkImage.h ('k') | src/gpu/vk/GrVkPipelineState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698