Chromium Code Reviews| Index: src/gpu/vk/GrVkProgram.cpp |
| diff --git a/src/gpu/vk/GrVkProgram.cpp b/src/gpu/vk/GrVkProgram.cpp |
| index d9d4336057c7bbe4721f9b1a4c2744c8527f7ddb..8535e0c78879325a94eb6636756cd05daed4565d 100644 |
| --- a/src/gpu/vk/GrVkProgram.cpp |
| +++ b/src/gpu/vk/GrVkProgram.cpp |
| @@ -14,6 +14,7 @@ |
| #include "GrVkImageView.h" |
| #include "GrVkMemory.h" |
| #include "GrVkPipeline.h" |
| +#include "GrVkRenderTarget.h" |
| #include "GrVkSampler.h" |
| #include "GrVkTexture.h" |
| #include "GrVkUniformBuffer.h" |
| @@ -22,6 +23,7 @@ |
| #include "glsl/GrGLSLXferProcessor.h" |
| GrVkProgram::GrVkProgram(GrVkGpu* gpu, |
| + const GrVkProgram::PipelineDesc& desc, |
| GrVkPipeline* pipeline, |
| VkPipelineLayout layout, |
| VkDescriptorSetLayout dsLayout[2], |
| @@ -39,6 +41,7 @@ GrVkProgram::GrVkProgram(GrVkGpu* gpu, |
| , fGeometryProcessor(geometryProcessor) |
| , fXferProcessor(xferProcessor) |
| , fFragmentProcessors(fragmentProcessors) |
| + , fPipelineDesc(desc) |
| , fProgramDataManager(uniforms, vertexUniformSize, fragmentUniformSize) |
| , fSamplerPoolManager(dsLayout[GrVkUniformHandler::kSamplerDescSet], |
| VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, numSamplers, gpu) |
| @@ -225,6 +228,13 @@ void GrVkProgram::writeUniformBuffers(const GrVkGpu* gpu) { |
| descriptorWrites[0].pImageInfo = nullptr; |
| descriptorWrites[0].pBufferInfo = &vertBufferInfo; |
| descriptorWrites[0].pTexelBufferView = nullptr; |
| + |
| + fVertexUniformBuffer->addMemoryBarrier(gpu, |
| + VK_ACCESS_HOST_WRITE_BIT, |
| + VK_ACCESS_UNIFORM_READ_BIT, |
| + VK_PIPELINE_STAGE_HOST_BIT, |
| + VK_PIPELINE_STAGE_VERTEX_SHADER_BIT, |
| + false); |
| } |
| VkDescriptorBufferInfo fragBufferInfo; |
| @@ -249,6 +259,13 @@ void GrVkProgram::writeUniformBuffers(const GrVkGpu* gpu) { |
| descriptorWrites[1].pImageInfo = nullptr; |
| descriptorWrites[1].pBufferInfo = &fragBufferInfo; |
| descriptorWrites[1].pTexelBufferView = nullptr; |
| + |
| + fFragmentUniformBuffer->addMemoryBarrier(gpu, |
| + VK_ACCESS_HOST_WRITE_BIT, |
| + VK_ACCESS_UNIFORM_READ_BIT, |
| + VK_PIPELINE_STAGE_HOST_BIT, |
| + VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT, |
| + false); |
| } |
| if (uniformBindingUpdateCount) { |
| @@ -411,7 +428,6 @@ void GrVkProgram::DescriptorPoolManager::getNewDescriptorSet(GrVkGpu* gpu, VkDes |
| dsAllocateInfo.descriptorPool = fPool->descPool(); |
| dsAllocateInfo.descriptorSetCount = 1; |
| dsAllocateInfo.pSetLayouts = &fDescLayout; |
| - |
| GR_VK_CALL_ERRCHECK(gpu->vkInterface(), AllocateDescriptorSets(gpu->device(), |
| &dsAllocateInfo, |
| ds)); |
| @@ -437,3 +453,46 @@ void GrVkProgram::DescriptorPoolManager::abandonGPUResources() { |
| fPool = nullptr; |
| } |
| } |
| + |
| +uint32_t get_blend_info_key(const GrPipeline& pipeline) { |
| + GrXferProcessor::BlendInfo blendInfo; |
| + pipeline.getXferProcessor().getBlendInfo(&blendInfo); |
| + |
| + static const uint32_t kBlendWriteShift = 1; |
| + static const uint32_t kBlendCoeffShift = 5; |
| + GR_STATIC_ASSERT(kLast_GrBlendCoeff < (1 << kBlendCoeffShift)); |
| + GR_STATIC_ASSERT(kFirstAdvancedGrBlendEquation - 1 < 4); |
| + |
| + uint32_t key = blendInfo.fWriteColor; |
| + key |= (blendInfo.fSrcBlend << kBlendWriteShift); |
| + key |= (blendInfo.fDstBlend << (kBlendWriteShift + kBlendCoeffShift)); |
| + key |= (blendInfo.fEquation << (kBlendWriteShift + 2 * kBlendCoeffShift)); |
| + |
| + return key; |
| +} |
| + |
| +void GrVkProgram::BuildVkKey(const GrPipeline& pipeline, GrPrimitiveType primitiveType, |
| + SkTArray<unsigned char, true>* key) { |
|
bsalomon
2016/03/22 14:00:33
uint8_t in the class and unsigned char here
egdaniel
2016/03/22 20:06:14
Done.
|
| + // Save room for the key length and key header |
| + key->reset(); |
| + key->push_back_n(kData_KeyOffset); |
| + |
| + GrProcessorKeyBuilder b(key); |
| + |
| + GrVkRenderTarget* vkRT = (GrVkRenderTarget*)pipeline.getRenderTarget(); |
| + vkRT->simpleRenderPass()->genKey(&b); |
| + |
| + pipeline.getStencil().genKey(&b); |
| + |
| + SkASSERT(sizeof(GrPipelineBuilder::DrawFace) <= sizeof(uint32_t)); |
| + b.add32(pipeline.getDrawFace()); |
| + |
| + b.add32(get_blend_info_key(pipeline)); |
| + |
| + b.add32(primitiveType); |
| + |
| + // Set key length |
| + int keyLength = key->count(); |
| + SkASSERT(0 == (keyLength % 4)); |
| + *reinterpret_cast<uint32_t*>(key->begin()) = SkToU32(keyLength); |
| +} |