Chromium Code Reviews| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 163 VkShaderModule fragShaderModule; | 163 VkShaderModule fragShaderModule; |
| 164 | 164 |
| 165 uint32_t numSamplers = fSamplerUniforms.count(); | 165 uint32_t numSamplers = fSamplerUniforms.count(); |
| 166 | 166 |
| 167 SkAutoTDeleteArray<VkDescriptorSetLayoutBinding> dsSamplerBindings( | 167 SkAutoTDeleteArray<VkDescriptorSetLayoutBinding> dsSamplerBindings( |
| 168 new VkDescriptorSetLayoutBi nding[numSamplers]); | 168 new VkDescriptorSetLayoutBi nding[numSamplers]); |
| 169 for (uint32_t i = 0; i < numSamplers; ++i) { | 169 for (uint32_t i = 0; i < numSamplers; ++i) { |
| 170 UniformHandle uniHandle = fSamplerUniforms[i]; | 170 UniformHandle uniHandle = fSamplerUniforms[i]; |
| 171 GrVkUniformHandler::UniformInfo uniformInfo = fUniformHandler.getUniform Info(uniHandle); | 171 GrVkUniformHandler::UniformInfo uniformInfo = fUniformHandler.getUniform Info(uniHandle); |
| 172 SkASSERT(kSampler2D_GrSLType == uniformInfo.fVariable.getType()); | 172 SkASSERT(kSampler2D_GrSLType == uniformInfo.fVariable.getType()); |
| 173 SkASSERT(0 == uniformInfo.fSetNumber); | 173 SkASSERT(GrVkUniformHandler::kSamplerDescSet == uniformInfo.fSetNumber); |
| 174 SkASSERT(uniformInfo.fBinding == i); | 174 SkASSERT(uniformInfo.fBinding == i); |
| 175 dsSamplerBindings[i].binding = uniformInfo.fBinding; | 175 dsSamplerBindings[i].binding = uniformInfo.fBinding; |
| 176 dsSamplerBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_ SAMPLER; | 176 dsSamplerBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_ SAMPLER; |
| 177 dsSamplerBindings[i].descriptorCount = 1; | 177 dsSamplerBindings[i].descriptorCount = 1; |
| 178 dsSamplerBindings[i].stageFlags = visibility_to_vk_stage_flags(uniformIn fo.fVisibility); | 178 dsSamplerBindings[i].stageFlags = visibility_to_vk_stage_flags(uniformIn fo.fVisibility); |
| 179 dsSamplerBindings[i].pImmutableSamplers = nullptr; | 179 dsSamplerBindings[i].pImmutableSamplers = nullptr; |
| 180 } | 180 } |
| 181 | 181 |
| 182 VkDescriptorSetLayoutCreateInfo dsSamplerLayoutCreateInfo; | 182 VkDescriptorSetLayoutCreateInfo dsSamplerLayoutCreateInfo; |
| 183 memset(&dsSamplerLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo )); | 183 memset(&dsSamplerLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo )); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 196 nullptr, | 196 nullptr, |
| 197 &dsLayout[GrVkUniformHandler:: kSamplerDescSet])); | 197 &dsLayout[GrVkUniformHandler:: kSamplerDescSet])); |
| 198 | 198 |
| 199 // Create Uniform Buffer Descriptor | 199 // Create Uniform Buffer Descriptor |
| 200 // We always attach uniform buffers to descriptor set 1. The vertex uniform buffer will have | 200 // We always attach uniform buffers to descriptor set 1. The vertex uniform buffer will have |
| 201 // binding 0 and the fragment binding 1. | 201 // binding 0 and the fragment binding 1. |
| 202 VkDescriptorSetLayoutBinding dsUniBindings[2]; | 202 VkDescriptorSetLayoutBinding dsUniBindings[2]; |
| 203 memset(&dsUniBindings, 0, 2 * sizeof(VkDescriptorSetLayoutBinding)); | 203 memset(&dsUniBindings, 0, 2 * sizeof(VkDescriptorSetLayoutBinding)); |
| 204 dsUniBindings[0].binding = GrVkUniformHandler::kVertexBinding; | 204 dsUniBindings[0].binding = GrVkUniformHandler::kVertexBinding; |
| 205 dsUniBindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | 205 dsUniBindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 206 dsUniBindings[0].descriptorCount = fUniformHandler.hasVertexUniforms() ? 1 : 0; | 206 dsUniBindings[0].descriptorCount = 1; |
|
egdaniel
2016/04/06 20:22:48
This is needed so that the layout for all our unif
| |
| 207 dsUniBindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; | 207 dsUniBindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; |
| 208 dsUniBindings[0].pImmutableSamplers = nullptr; | 208 dsUniBindings[0].pImmutableSamplers = nullptr; |
| 209 dsUniBindings[1].binding = GrVkUniformHandler::kFragBinding; | 209 dsUniBindings[1].binding = GrVkUniformHandler::kFragBinding; |
| 210 dsUniBindings[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; | 210 dsUniBindings[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; |
| 211 dsUniBindings[1].descriptorCount = fUniformHandler.hasFragmentUniforms() ? 1 : 0; | 211 dsUniBindings[1].descriptorCount = 1; |
| 212 dsUniBindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; | 212 dsUniBindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; |
| 213 dsUniBindings[1].pImmutableSamplers = nullptr; | 213 dsUniBindings[1].pImmutableSamplers = nullptr; |
| 214 | 214 |
| 215 VkDescriptorSetLayoutCreateInfo dsUniformLayoutCreateInfo; | 215 VkDescriptorSetLayoutCreateInfo dsUniformLayoutCreateInfo; |
| 216 memset(&dsUniformLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo )); | 216 memset(&dsUniformLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo )); |
| 217 dsUniformLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CR EATE_INFO; | 217 dsUniformLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CR EATE_INFO; |
| 218 dsUniformLayoutCreateInfo.pNext = nullptr; | 218 dsUniformLayoutCreateInfo.pNext = nullptr; |
| 219 dsUniformLayoutCreateInfo.flags = 0; | 219 dsUniformLayoutCreateInfo.flags = 0; |
| 220 dsUniformLayoutCreateInfo.bindingCount = 2; | 220 dsUniformLayoutCreateInfo.bindingCount = 2; |
| 221 dsUniformLayoutCreateInfo.pBindings = dsUniBindings; | 221 dsUniformLayoutCreateInfo.pBindings = dsUniBindings; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 294 dsLayout, | 294 dsLayout, |
| 295 fUniformHandles, | 295 fUniformHandles, |
| 296 fUniformHandler.fUniforms, | 296 fUniformHandler.fUniforms, |
| 297 fUniformHandler.fCurrentVertexUBOOffset, | 297 fUniformHandler.fCurrentVertexUBOOffset, |
| 298 fUniformHandler.fCurrentFragmentUBOOffset, | 298 fUniformHandler.fCurrentFragmentUBOOffset, |
| 299 numSamplers, | 299 numSamplers, |
| 300 fGeometryProcessor, | 300 fGeometryProcessor, |
| 301 fXferProcessor, | 301 fXferProcessor, |
| 302 fFragmentProcessors); | 302 fFragmentProcessors); |
| 303 } | 303 } |
| OLD | NEW |