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 "GrVkCommandBuffer.h" | 8 #include "GrVkCommandBuffer.h" |
9 | 9 |
10 #include "GrVkFramebuffer.h" | 10 #include "GrVkFramebuffer.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 fCachedBlendConstant[i] = -1.0; | 56 fCachedBlendConstant[i] = -1.0; |
57 } | 57 } |
58 } | 58 } |
59 | 59 |
60 void GrVkCommandBuffer::freeGPUData(const GrVkGpu* gpu) const { | 60 void GrVkCommandBuffer::freeGPUData(const GrVkGpu* gpu) const { |
61 SkASSERT(!fIsActive); | 61 SkASSERT(!fIsActive); |
62 SkASSERT(!fActiveRenderPass); | 62 SkASSERT(!fActiveRenderPass); |
63 for (int i = 0; i < fTrackedResources.count(); ++i) { | 63 for (int i = 0; i < fTrackedResources.count(); ++i) { |
64 fTrackedResources[i]->unref(gpu); | 64 fTrackedResources[i]->unref(gpu); |
65 } | 65 } |
66 | 66 |
67 // Destroy the fence, if any | 67 // Destroy the fence, if any |
68 if (VK_NULL_HANDLE != fSubmitFence) { | 68 if (VK_NULL_HANDLE != fSubmitFence) { |
69 GR_VK_CALL(gpu->vkInterface(), DestroyFence(gpu->device(), fSubmitFence,
nullptr)); | 69 GR_VK_CALL(gpu->vkInterface(), DestroyFence(gpu->device(), fSubmitFence,
nullptr)); |
70 } | 70 } |
71 | 71 |
72 GR_VK_CALL(gpu->vkInterface(), FreeCommandBuffers(gpu->device(), gpu->cmdPoo
l(), | 72 GR_VK_CALL(gpu->vkInterface(), FreeCommandBuffers(gpu->device(), gpu->cmdPoo
l(), |
73 1, &fCmdBuffer)); | 73 1, &fCmdBuffer)); |
74 } | 74 } |
75 | 75 |
76 void GrVkCommandBuffer::abandonSubResources() const { | 76 void GrVkCommandBuffer::abandonSubResources() const { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 | 119 |
120 void GrVkCommandBuffer::endRenderPass(const GrVkGpu* gpu) { | 120 void GrVkCommandBuffer::endRenderPass(const GrVkGpu* gpu) { |
121 SkASSERT(fIsActive); | 121 SkASSERT(fIsActive); |
122 SkASSERT(fActiveRenderPass); | 122 SkASSERT(fActiveRenderPass); |
123 GR_VK_CALL(gpu->vkInterface(), CmdEndRenderPass(fCmdBuffer)); | 123 GR_VK_CALL(gpu->vkInterface(), CmdEndRenderPass(fCmdBuffer)); |
124 fActiveRenderPass = nullptr; | 124 fActiveRenderPass = nullptr; |
125 } | 125 } |
126 | 126 |
127 void GrVkCommandBuffer::submitToQueue(const GrVkGpu* gpu, VkQueue queue, GrVkGpu
::SyncQueue sync) { | 127 void GrVkCommandBuffer::submitToQueue(const GrVkGpu* gpu, VkQueue queue, GrVkGpu
::SyncQueue sync) { |
128 SkASSERT(!fIsActive); | 128 SkASSERT(!fIsActive); |
129 | 129 |
130 VkResult err; | 130 VkResult err; |
131 VkFenceCreateInfo fenceInfo; | 131 VkFenceCreateInfo fenceInfo; |
132 memset(&fenceInfo, 0, sizeof(VkFenceCreateInfo)); | 132 memset(&fenceInfo, 0, sizeof(VkFenceCreateInfo)); |
133 fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; | 133 fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; |
134 err = GR_VK_CALL(gpu->vkInterface(), CreateFence(gpu->device(), &fenceInfo,
nullptr, | 134 err = GR_VK_CALL(gpu->vkInterface(), CreateFence(gpu->device(), &fenceInfo,
nullptr, |
135 &fSubmitFence)); | 135 &fSubmitFence)); |
136 SkASSERT(!err); | 136 SkASSERT(!err); |
137 | 137 |
138 VkSubmitInfo submitInfo; | 138 VkSubmitInfo submitInfo; |
139 memset(&submitInfo, 0, sizeof(VkSubmitInfo)); | 139 memset(&submitInfo, 0, sizeof(VkSubmitInfo)); |
140 submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; | 140 submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; |
141 submitInfo.pNext = nullptr; | 141 submitInfo.pNext = nullptr; |
142 submitInfo.waitSemaphoreCount = 0; | 142 submitInfo.waitSemaphoreCount = 0; |
143 submitInfo.pWaitSemaphores = nullptr; | 143 submitInfo.pWaitSemaphores = nullptr; |
144 submitInfo.commandBufferCount = 1; | 144 submitInfo.commandBufferCount = 1; |
145 submitInfo.pCommandBuffers = &fCmdBuffer; | 145 submitInfo.pCommandBuffers = &fCmdBuffer; |
146 submitInfo.signalSemaphoreCount = 0; | 146 submitInfo.signalSemaphoreCount = 0; |
147 submitInfo.pSignalSemaphores = nullptr; | 147 submitInfo.pSignalSemaphores = nullptr; |
148 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), QueueSubmit(queue, 1, &submitInfo, f
SubmitFence)); | 148 GR_VK_CALL_ERRCHECK(gpu->vkInterface(), QueueSubmit(queue, 1, &submitInfo, f
SubmitFence)); |
149 | 149 |
150 if (GrVkGpu::kForce_SyncQueue == sync) { | 150 if (GrVkGpu::kForce_SyncQueue == sync) { |
151 err = GR_VK_CALL(gpu->vkInterface(), | 151 err = GR_VK_CALL(gpu->vkInterface(), |
152 WaitForFences(gpu->device(), 1, &fSubmitFence, true, UI
NT64_MAX)); | 152 WaitForFences(gpu->device(), 1, &fSubmitFence, true, UI
NT64_MAX)); |
153 if (VK_TIMEOUT == err) { | 153 if (VK_TIMEOUT == err) { |
154 SkDebugf("Fence failed to signal: %d\n", err); | 154 SkDebugf("Fence failed to signal: %d\n", err); |
155 SkFAIL("failing"); | 155 SkFAIL("failing"); |
156 } | 156 } |
157 SkASSERT(!err); | 157 SkASSERT(!err); |
158 | 158 |
159 // Destroy the fence | 159 // Destroy the fence |
160 GR_VK_CALL(gpu->vkInterface(), DestroyFence(gpu->device(), fSubmitFence,
nullptr)); | 160 GR_VK_CALL(gpu->vkInterface(), DestroyFence(gpu->device(), fSubmitFence,
nullptr)); |
161 fSubmitFence = VK_NULL_HANDLE; | 161 fSubmitFence = VK_NULL_HANDLE; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 } | 436 } |
437 | 437 |
438 void GrVkCommandBuffer::setBlendConstants(const GrVkGpu* gpu, | 438 void GrVkCommandBuffer::setBlendConstants(const GrVkGpu* gpu, |
439 const float blendConstants[4]) { | 439 const float blendConstants[4]) { |
440 SkASSERT(fIsActive); | 440 SkASSERT(fIsActive); |
441 if (memcmp(blendConstants, fCachedBlendConstant, 4 * sizeof(float))) { | 441 if (memcmp(blendConstants, fCachedBlendConstant, 4 * sizeof(float))) { |
442 GR_VK_CALL(gpu->vkInterface(), CmdSetBlendConstants(fCmdBuffer, blendCon
stants)); | 442 GR_VK_CALL(gpu->vkInterface(), CmdSetBlendConstants(fCmdBuffer, blendCon
stants)); |
443 memcpy(fCachedBlendConstant, blendConstants, 4 * sizeof(float)); | 443 memcpy(fCachedBlendConstant, blendConstants, 4 * sizeof(float)); |
444 } | 444 } |
445 } | 445 } |
OLD | NEW |