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

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

Issue 1896013003: Revert of Refactor how we store and use samplers in Ganesh (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: 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/GrVkGLSLSampler.h ('k') | src/gpu/vk/GrVkPipelineStateDataManager.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 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
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
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 }
OLDNEW
« no previous file with comments | « src/gpu/vk/GrVkGLSLSampler.h ('k') | src/gpu/vk/GrVkPipelineStateDataManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698