| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2016 Google Inc. | 2 * Copyright 2016 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 "vk/GrVkPipelineStateBuilder.h" | 8 #include "vk/GrVkPipelineStateBuilder.h" |
| 9 | 9 |
| 10 #include "vk/GrVkGpu.h" | 10 #include "vk/GrVkGpu.h" |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // Setting to nullptr fixes an error in the param checker validation layer.
Even though | 186 // Setting to nullptr fixes an error in the param checker validation layer.
Even though |
| 187 // bindingCount is 0 (which is valid), it still tries to validate pBindings
unless it is null. | 187 // bindingCount is 0 (which is valid), it still tries to validate pBindings
unless it is null. |
| 188 dsSamplerLayoutCreateInfo.pBindings = numSamplers ? dsSamplerBindings.get()
: nullptr; | 188 dsSamplerLayoutCreateInfo.pBindings = numSamplers ? dsSamplerBindings.get()
: nullptr; |
| 189 | 189 |
| 190 GR_VK_CALL_ERRCHECK(fGpu->vkInterface(), | 190 GR_VK_CALL_ERRCHECK(fGpu->vkInterface(), |
| 191 CreateDescriptorSetLayout(fGpu->device(), | 191 CreateDescriptorSetLayout(fGpu->device(), |
| 192 &dsSamplerLayoutCreateInfo, | 192 &dsSamplerLayoutCreateInfo, |
| 193 nullptr, | 193 nullptr, |
| 194 &dsLayout[GrVkUniformHandler::
kSamplerDescSet])); | 194 &dsLayout[GrVkUniformHandler::
kSamplerDescSet])); |
| 195 | 195 |
| 196 // Create Uniform Buffer Descriptor | 196 // This layout is not owned by the PipelineStateBuilder and thus should no b
e destroyed |
| 197 // We always attach uniform buffers to descriptor set 1. The vertex uniform
buffer will have | 197 dsLayout[GrVkUniformHandler::kUniformBufferDescSet] = fGpu->resourceProvider
().getUniDSLayout(); |
| 198 // binding 0 and the fragment binding 1. | |
| 199 VkDescriptorSetLayoutBinding dsUniBindings[2]; | |
| 200 memset(&dsUniBindings, 0, 2 * sizeof(VkDescriptorSetLayoutBinding)); | |
| 201 dsUniBindings[0].binding = GrVkUniformHandler::kVertexBinding; | |
| 202 dsUniBindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | |
| 203 dsUniBindings[0].descriptorCount = 1; | |
| 204 dsUniBindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; | |
| 205 dsUniBindings[0].pImmutableSamplers = nullptr; | |
| 206 dsUniBindings[1].binding = GrVkUniformHandler::kFragBinding; | |
| 207 dsUniBindings[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | |
| 208 dsUniBindings[1].descriptorCount = 1; | |
| 209 dsUniBindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; | |
| 210 dsUniBindings[1].pImmutableSamplers = nullptr; | |
| 211 | |
| 212 VkDescriptorSetLayoutCreateInfo dsUniformLayoutCreateInfo; | |
| 213 memset(&dsUniformLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo
)); | |
| 214 dsUniformLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CR
EATE_INFO; | |
| 215 dsUniformLayoutCreateInfo.pNext = nullptr; | |
| 216 dsUniformLayoutCreateInfo.flags = 0; | |
| 217 dsUniformLayoutCreateInfo.bindingCount = 2; | |
| 218 dsUniformLayoutCreateInfo.pBindings = dsUniBindings; | |
| 219 | |
| 220 GR_VK_CALL_ERRCHECK(fGpu->vkInterface(), CreateDescriptorSetLayout( | |
| 221 fGpu->device(), | |
| 222 &dsUniformLayoutCreateInfo, | |
| 223 nullptr, | |
| 224 &dsLayout[GrVkUniformHandler::kUnif
ormBufferDescSet])); | |
| 225 | 198 |
| 226 // Create the VkPipelineLayout | 199 // Create the VkPipelineLayout |
| 227 VkPipelineLayoutCreateInfo layoutCreateInfo; | 200 VkPipelineLayoutCreateInfo layoutCreateInfo; |
| 228 memset(&layoutCreateInfo, 0, sizeof(VkPipelineLayoutCreateFlags)); | 201 memset(&layoutCreateInfo, 0, sizeof(VkPipelineLayoutCreateFlags)); |
| 229 layoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; | 202 layoutCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; |
| 230 layoutCreateInfo.pNext = 0; | 203 layoutCreateInfo.pNext = 0; |
| 231 layoutCreateInfo.flags = 0; | 204 layoutCreateInfo.flags = 0; |
| 232 layoutCreateInfo.setLayoutCount = 2; | 205 layoutCreateInfo.setLayoutCount = 2; |
| 233 layoutCreateInfo.pSetLayouts = dsLayout; | 206 layoutCreateInfo.pSetLayouts = dsLayout; |
| 234 layoutCreateInfo.pushConstantRangeCount = 0; | 207 layoutCreateInfo.pushConstantRangeCount = 0; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 renderPass, | 243 renderPass, |
| 271 pipelineLayout); | 244 pipelineLayout); |
| 272 GR_VK_CALL(fGpu->vkInterface(), DestroyShaderModule(fGpu->device(), vertShad
erModule, | 245 GR_VK_CALL(fGpu->vkInterface(), DestroyShaderModule(fGpu->device(), vertShad
erModule, |
| 273 nullptr)); | 246 nullptr)); |
| 274 GR_VK_CALL(fGpu->vkInterface(), DestroyShaderModule(fGpu->device(), fragShad
erModule, | 247 GR_VK_CALL(fGpu->vkInterface(), DestroyShaderModule(fGpu->device(), fragShad
erModule, |
| 275 nullptr)); | 248 nullptr)); |
| 276 | 249 |
| 277 if (!pipeline) { | 250 if (!pipeline) { |
| 278 GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineLayout(fGpu->device(), pi
pelineLayout, | 251 GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineLayout(fGpu->device(), pi
pelineLayout, |
| 279 nullptr)); | 252 nullptr)); |
| 280 GR_VK_CALL(fGpu->vkInterface(), DestroyDescriptorSetLayout(fGpu->device(
), dsLayout[0], | 253 GR_VK_CALL(fGpu->vkInterface(), |
| 281 nullptr)); | 254 DestroyDescriptorSetLayout(fGpu->device(), |
| 282 GR_VK_CALL(fGpu->vkInterface(), DestroyDescriptorSetLayout(fGpu->device(
), dsLayout[1], | 255 dsLayout[GrVkUniformHandler::kSamp
lerDescSet], |
| 283 nullptr)); | 256 nullptr)); |
| 257 |
| 284 this->cleanupFragmentProcessors(); | 258 this->cleanupFragmentProcessors(); |
| 285 return nullptr; | 259 return nullptr; |
| 286 } | 260 } |
| 287 | 261 |
| 288 return new GrVkPipelineState(fGpu, | 262 return new GrVkPipelineState(fGpu, |
| 289 desc, | 263 desc, |
| 290 pipeline, | 264 pipeline, |
| 291 pipelineLayout, | 265 pipelineLayout, |
| 292 dsLayout, | 266 dsLayout[GrVkUniformHandler::kSamplerDescSet], |
| 293 fUniformHandles, | 267 fUniformHandles, |
| 294 fUniformHandler.fUniforms, | 268 fUniformHandler.fUniforms, |
| 295 fUniformHandler.fCurrentVertexUBOOffset, | 269 fUniformHandler.fCurrentVertexUBOOffset, |
| 296 fUniformHandler.fCurrentFragmentUBOOffset, | 270 fUniformHandler.fCurrentFragmentUBOOffset, |
| 297 numSamplers, | 271 numSamplers, |
| 298 fGeometryProcessor, | 272 fGeometryProcessor, |
| 299 fXferProcessor, | 273 fXferProcessor, |
| 300 fFragmentProcessors); | 274 fFragmentProcessors); |
| 301 } | 275 } |
| OLD | NEW |