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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 } | 155 } |
156 | 156 |
157 GrVkPipelineState* GrVkPipelineStateBuilder::finalize(GrPrimitiveType primitiveT
ype, | 157 GrVkPipelineState* GrVkPipelineStateBuilder::finalize(GrPrimitiveType primitiveT
ype, |
158 const GrVkRenderPass& rend
erPass, | 158 const GrVkRenderPass& rend
erPass, |
159 const GrVkPipelineState::D
esc& desc) { | 159 const GrVkPipelineState::D
esc& desc) { |
160 VkDescriptorSetLayout dsLayout[2]; | 160 VkDescriptorSetLayout dsLayout[2]; |
161 VkPipelineLayout pipelineLayout; | 161 VkPipelineLayout pipelineLayout; |
162 VkShaderModule vertShaderModule; | 162 VkShaderModule vertShaderModule; |
163 VkShaderModule fragShaderModule; | 163 VkShaderModule fragShaderModule; |
164 | 164 |
165 uint32_t numSamplers = (uint32_t)fUniformHandler.numSamplers(); | 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 const GrVkGLSLSampler& sampler = | 170 UniformHandle uniHandle = fSamplerUniforms[i]; |
171 static_cast<const GrVkGLSLSampler&>(fUniformHandler.getSampler(i)); | 171 GrVkUniformHandler::UniformInfo uniformInfo = fUniformHandler.getUniform
Info(uniHandle); |
172 SkASSERT(sampler.binding() == i); | 172 SkASSERT(kSampler2D_GrSLType == uniformInfo.fVariable.getType()); |
173 dsSamplerBindings[i].binding = sampler.binding(); | 173 SkASSERT(GrVkUniformHandler::kSamplerDescSet == uniformInfo.fSetNumber); |
| 174 SkASSERT(uniformInfo.fBinding == i); |
| 175 dsSamplerBindings[i].binding = uniformInfo.fBinding; |
174 dsSamplerBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_
SAMPLER; | 176 dsSamplerBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_
SAMPLER; |
175 dsSamplerBindings[i].descriptorCount = 1; | 177 dsSamplerBindings[i].descriptorCount = 1; |
176 dsSamplerBindings[i].stageFlags = visibility_to_vk_stage_flags(sampler.v
isibility()); | 178 dsSamplerBindings[i].stageFlags = visibility_to_vk_stage_flags(uniformIn
fo.fVisibility); |
177 dsSamplerBindings[i].pImmutableSamplers = nullptr; | 179 dsSamplerBindings[i].pImmutableSamplers = nullptr; |
178 } | 180 } |
179 | 181 |
180 VkDescriptorSetLayoutCreateInfo dsSamplerLayoutCreateInfo; | 182 VkDescriptorSetLayoutCreateInfo dsSamplerLayoutCreateInfo; |
181 memset(&dsSamplerLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo
)); | 183 memset(&dsSamplerLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo
)); |
182 dsSamplerLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CR
EATE_INFO; | 184 dsSamplerLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CR
EATE_INFO; |
183 dsSamplerLayoutCreateInfo.pNext = nullptr; | 185 dsSamplerLayoutCreateInfo.pNext = nullptr; |
184 dsSamplerLayoutCreateInfo.flags = 0; | 186 dsSamplerLayoutCreateInfo.flags = 0; |
185 dsSamplerLayoutCreateInfo.bindingCount = numSamplers; | 187 dsSamplerLayoutCreateInfo.bindingCount = fSamplerUniforms.count(); |
186 // Setting to nullptr fixes an error in the param checker validation layer.
Even though | 188 // 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. | 189 // bindingCount is 0 (which is valid), it still tries to validate pBindings
unless it is null. |
188 dsSamplerLayoutCreateInfo.pBindings = numSamplers ? dsSamplerBindings.get()
: nullptr; | 190 dsSamplerLayoutCreateInfo.pBindings = fSamplerUniforms.count() ? dsSamplerBi
ndings.get() : |
| 191 nullptr; |
189 | 192 |
190 GR_VK_CALL_ERRCHECK(fGpu->vkInterface(), | 193 GR_VK_CALL_ERRCHECK(fGpu->vkInterface(), |
191 CreateDescriptorSetLayout(fGpu->device(), | 194 CreateDescriptorSetLayout(fGpu->device(), |
192 &dsSamplerLayoutCreateInfo, | 195 &dsSamplerLayoutCreateInfo, |
193 nullptr, | 196 nullptr, |
194 &dsLayout[GrVkUniformHandler::
kSamplerDescSet])); | 197 &dsLayout[GrVkUniformHandler::
kSamplerDescSet])); |
195 | 198 |
196 // Create Uniform Buffer Descriptor | 199 // Create Uniform Buffer Descriptor |
197 // 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 |
198 // binding 0 and the fragment binding 1. | 201 // binding 0 and the fragment binding 1. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 dsLayout, | 295 dsLayout, |
293 fUniformHandles, | 296 fUniformHandles, |
294 fUniformHandler.fUniforms, | 297 fUniformHandler.fUniforms, |
295 fUniformHandler.fCurrentVertexUBOOffset, | 298 fUniformHandler.fCurrentVertexUBOOffset, |
296 fUniformHandler.fCurrentFragmentUBOOffset, | 299 fUniformHandler.fCurrentFragmentUBOOffset, |
297 numSamplers, | 300 numSamplers, |
298 fGeometryProcessor, | 301 fGeometryProcessor, |
299 fXferProcessor, | 302 fXferProcessor, |
300 fFragmentProcessors); | 303 fFragmentProcessors); |
301 } | 304 } |
OLD | NEW |