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 "GrVkPipelineState.h" | 8 #include "GrVkPipelineState.h" |
9 | 9 |
10 #include "GrPipeline.h" | 10 #include "GrPipeline.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 append_texture_bindings(processor, &textureBindings); | 196 append_texture_bindings(processor, &textureBindings); |
197 } | 197 } |
198 | 198 |
199 fXferProcessor->setData(fDataManager, pipeline.getXferProcessor()); | 199 fXferProcessor->setData(fDataManager, pipeline.getXferProcessor()); |
200 append_texture_bindings(pipeline.getXferProcessor(), &textureBindings); | 200 append_texture_bindings(pipeline.getXferProcessor(), &textureBindings); |
201 | 201 |
202 // Get new descriptor sets | 202 // Get new descriptor sets |
203 if (fNumSamplers) { | 203 if (fNumSamplers) { |
204 fSamplerPoolManager.getNewDescriptorSet(gpu, | 204 fSamplerPoolManager.getNewDescriptorSet(gpu, |
205 &fDescriptorSets[GrVkUniformHandler
::kSamplerDescSet]); | 205 &fDescriptorSets[GrVkUniformHandler
::kSamplerDescSet]); |
206 this->writeSamplers(gpu, textureBindings); | 206 this->writeSamplers(gpu, textureBindings, pipeline.getAllowSRGBInputs())
; |
207 } | 207 } |
208 | 208 |
209 if (fVertexUniformBuffer.get() || fFragmentUniformBuffer.get()) { | 209 if (fVertexUniformBuffer.get() || fFragmentUniformBuffer.get()) { |
210 if (fDataManager.uploadUniformBuffers(gpu, fVertexUniformBuffer, fFragme
ntUniformBuffer) || | 210 if (fDataManager.uploadUniformBuffers(gpu, fVertexUniformBuffer, fFragme
ntUniformBuffer) || |
211 VK_NULL_HANDLE == fDescriptorSets[GrVkUniformHandler::kUniformBuffer
DescSet]) { | 211 VK_NULL_HANDLE == fDescriptorSets[GrVkUniformHandler::kUniformBuffer
DescSet]) { |
212 const GrVkDescriptorPool* pool; | 212 const GrVkDescriptorPool* pool; |
213 int uniformDSIdx = GrVkUniformHandler::kUniformBufferDescSet; | 213 int uniformDSIdx = GrVkUniformHandler::kUniformBufferDescSet; |
214 gpu->resourceProvider().getUniformDescriptorSet(&fDescriptorSets[uni
formDSIdx], | 214 gpu->resourceProvider().getUniformDescriptorSet(&fDescriptorSets[uni
formDSIdx], |
215 &pool); | 215 &pool); |
216 if (pool != fCurrentUniformDescPool) { | 216 if (pool != fCurrentUniformDescPool) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 279 |
280 if (uniformBindingUpdateCount) { | 280 if (uniformBindingUpdateCount) { |
281 GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(), | 281 GR_VK_CALL(gpu->vkInterface(), UpdateDescriptorSets(gpu->device(), |
282 uniformBindingUpdate
Count, | 282 uniformBindingUpdate
Count, |
283 &descriptorWrites[fi
rstUniformWrite], | 283 &descriptorWrites[fi
rstUniformWrite], |
284 0, nullptr)); | 284 0, nullptr)); |
285 } | 285 } |
286 } | 286 } |
287 | 287 |
288 void GrVkPipelineState::writeSamplers(GrVkGpu* gpu, | 288 void GrVkPipelineState::writeSamplers(GrVkGpu* gpu, |
289 const SkTArray<const GrTextureAccess*>& te
xtureBindings) { | 289 const SkTArray<const GrTextureAccess*>& te
xtureBindings, |
| 290 bool allowSRGBInputs) { |
290 SkASSERT(fNumSamplers == textureBindings.count()); | 291 SkASSERT(fNumSamplers == textureBindings.count()); |
291 | 292 |
292 for (int i = 0; i < textureBindings.count(); ++i) { | 293 for (int i = 0; i < textureBindings.count(); ++i) { |
293 const GrTextureParams& params = textureBindings[i]->getParams(); | 294 const GrTextureParams& params = textureBindings[i]->getParams(); |
294 | 295 |
295 GrVkTexture* texture = static_cast<GrVkTexture*>(textureBindings[i]->get
Texture()); | 296 GrVkTexture* texture = static_cast<GrVkTexture*>(textureBindings[i]->get
Texture()); |
296 if (GrTextureParams::kMipMap_FilterMode == params.filterMode()) { | 297 if (GrTextureParams::kMipMap_FilterMode == params.filterMode()) { |
297 if (texture->texturePriv().mipMapsAreDirty()) { | 298 if (texture->texturePriv().mipMapsAreDirty()) { |
298 gpu->generateMipmap(texture); | 299 gpu->generateMipmap(texture); |
299 texture->texturePriv().dirtyMipMaps(false); | 300 texture->texturePriv().dirtyMipMaps(false); |
300 } | 301 } |
301 } | 302 } |
302 | 303 |
303 fSamplers.push(gpu->resourceProvider().findOrCreateCompatibleSampler(par
ams, | 304 fSamplers.push(gpu->resourceProvider().findOrCreateCompatibleSampler(par
ams, |
304 texture->texturePriv()
.maxMipMapLevel())); | 305 texture->texturePriv()
.maxMipMapLevel())); |
305 | 306 |
306 const GrVkImage::Resource* textureResource = texture->resource(); | 307 const GrVkImage::Resource* textureResource = texture->resource(); |
307 textureResource->ref(); | 308 textureResource->ref(); |
308 fTextures.push(textureResource); | 309 fTextures.push(textureResource); |
309 | 310 |
310 const GrVkImageView* textureView = texture->textureView(); | 311 const GrVkImageView* textureView = texture->textureView(allowSRGBInputs)
; |
311 textureView->ref(); | 312 textureView->ref(); |
312 fTextureViews.push(textureView); | 313 fTextureViews.push(textureView); |
313 | 314 |
314 // Change texture layout so it can be read in shader | 315 // Change texture layout so it can be read in shader |
315 texture->setImageLayout(gpu, | 316 texture->setImageLayout(gpu, |
316 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, | 317 VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, |
317 VK_ACCESS_SHADER_READ_BIT, | 318 VK_ACCESS_SHADER_READ_BIT, |
318 VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, | 319 VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT, |
319 false); | 320 false); |
320 | 321 |
321 VkDescriptorImageInfo imageInfo; | 322 VkDescriptorImageInfo imageInfo; |
322 memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo)); | 323 memset(&imageInfo, 0, sizeof(VkDescriptorImageInfo)); |
323 imageInfo.sampler = fSamplers[i]->sampler(); | 324 imageInfo.sampler = fSamplers[i]->sampler(); |
324 imageInfo.imageView = texture->textureView()->imageView(); | 325 imageInfo.imageView = textureView->imageView(); |
325 imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; | 326 imageInfo.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; |
326 | 327 |
327 VkWriteDescriptorSet writeInfo; | 328 VkWriteDescriptorSet writeInfo; |
328 memset(&writeInfo, 0, sizeof(VkWriteDescriptorSet)); | 329 memset(&writeInfo, 0, sizeof(VkWriteDescriptorSet)); |
329 writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; | 330 writeInfo.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; |
330 writeInfo.pNext = nullptr; | 331 writeInfo.pNext = nullptr; |
331 writeInfo.dstSet = fDescriptorSets[GrVkUniformHandler::kSamplerDescSet]; | 332 writeInfo.dstSet = fDescriptorSets[GrVkUniformHandler::kSamplerDescSet]; |
332 writeInfo.dstBinding = i; | 333 writeInfo.dstBinding = i; |
333 writeInfo.dstArrayElement = 0; | 334 writeInfo.dstArrayElement = 0; |
334 writeInfo.descriptorCount = 1; | 335 writeInfo.descriptorCount = 1; |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 | 504 |
504 b.add32(get_blend_info_key(pipeline)); | 505 b.add32(get_blend_info_key(pipeline)); |
505 | 506 |
506 b.add32(primitiveType); | 507 b.add32(primitiveType); |
507 | 508 |
508 // Set key length | 509 // Set key length |
509 int keyLength = key->count(); | 510 int keyLength = key->count(); |
510 SkASSERT(0 == (keyLength % 4)); | 511 SkASSERT(0 == (keyLength % 4)); |
511 *reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength); | 512 *reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength); |
512 } | 513 } |
OLD | NEW |