32bool GrVkMSAALoadManager::createMSAALoadProgram(
GrVkGpu* gpu) {
35 std::string vertShaderText;
36 vertShaderText.append(
37 "layout(vulkan, set=0, binding=0) uniform vertexUniformBuffer {"
41 "// MSAA Load Program VS\n"
43 "float2 position = float2(sk_VertexID >> 1, sk_VertexID & 1);"
44 "sk_Position.xy = position * uPosXform.xy + uPosXform.zw;"
45 "sk_Position.zw = half2(0, 1);"
48 std::string fragShaderText;
49 fragShaderText.append(
50 "layout(vulkan, input_attachment_index=0, set=2, binding=0) subpassInput uInput;"
52 "// MSAA Load Program FS\n"
54 "sk_FragColor = subpassLoad(uInput);"
61 &fVertShaderModule, &fShaderStageInfo[0],
settings, &spirv,
69 &fFragShaderModule, &fShaderStageInfo[1],
settings, &spirv,
87 GrVkDescriptorSetManager::Handle samplerHandle;
99 layoutCreateInfo.
pNext =
nullptr;
100 layoutCreateInfo.
flags = 0;
108 CreatePipelineLayout(gpu->
device(), &layoutCreateInfo,
nullptr, &fPipelineLayout));
126 if (!
src || !
src->supportsInputAttachmentUsage()) {
132 if (!this->createMSAALoadProgram(gpu)) {
133 SkDebugf(
"Failed to create copy program.\n");
143 fShaderStageInfo, fPipelineLayout);
166 commandBuffer->
setScissor(gpu, 0, 1, &scissor);
169 int w =
rect.width();
170 int h =
rect.height();
173 int dw =
dst->width();
174 int dh =
dst->height();
175 float dx0 = 2.f *
rect.fLeft / dw - 1.f;
176 float dx1 = 2.f * (
rect.fLeft +
w) / dw - 1.f;
177 float dy0 = 2.f *
rect.fTop / dh - 1.f;
178 float dy1 = 2.f * (
rect.fTop +
h) / dh - 1.f;
180 float uniData[] = {dx1 - dx0, dy1 - dy0, dx0, dy0};
190 if (!uniformBuffer) {
199 commandBuffer->
addGrBuffer(std::move(uniformBuffer));
208 inputDS->descriptorSet(),
215 commandBuffer->
draw(gpu, 4, 1, 0, 0);
223 DestroyShaderModule(gpu->
device(), fVertShaderModule,
nullptr));
229 DestroyShaderModule(gpu->
device(), fFragShaderModule,
nullptr));
235 DestroyPipelineLayout(gpu->
device(), fPipelineLayout,
nullptr));
@ kDynamic_GrAccessPattern
bool GrCompileVkShaderModule(GrVkGpu *gpu, const std::string &shaderString, VkShaderStageFlagBits stage, VkShaderModule *shaderModule, VkPipelineShaderStageCreateInfo *stageInfo, const SkSL::ProgramSettings &settings, std::string *outSPIRV, SkSL::Program::Interface *outInterface)
#define GR_VK_CALL(IFACE, X)
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
GrResourceProvider * resourceProvider()
GrDirectContextPriv priv()
GrDirectContext * getContext()
sk_sp< GrGpuBuffer > createBuffer(size_t size, GrGpuBufferType, GrAccessPattern, ZeroInit)
const VkDescriptorSet * uniformDescriptorSet() const
void setViewport(const GrVkGpu *gpu, uint32_t firstViewport, uint32_t viewportCount, const VkViewport *viewports)
void bindPipeline(const GrVkGpu *gpu, sk_sp< const GrVkPipeline > pipeline)
void addRecycledResource(gr_rp< const GrRecycledResource > resource)
void setScissor(const GrVkGpu *gpu, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *scissors)
void addGrBuffer(sk_sp< const GrBuffer > buffer)
void bindDescriptorSets(const GrVkGpu *gpu, VkPipelineLayout layout, uint32_t firstSet, uint32_t setCount, const VkDescriptorSet *descriptorSets, uint32_t dynamicOffsetCount, const uint32_t *dynamicOffsets)
void draw(const GrVkGpu *gpu, uint32_t vertexCount, uint32_t instanceCount, uint32_t firstVertex, uint32_t firstInstance)
const skgpu::VulkanInterface * vkInterface() const
GrVkResourceProvider & resourceProvider()
bool loadMSAAFromResolve(GrVkGpu *gpu, GrVkCommandBuffer *commandBuffer, const GrVkRenderPass &renderPass, GrAttachment *dst, GrVkImage *src, const SkIRect &srcRect)
void destroyResources(GrVkGpu *gpu)
VkDescriptorSetLayout getInputDSLayout() const
VkDescriptorSetLayout getUniformDSLayout() const
VkDescriptorSetLayout getSamplerDSLayout(const GrVkDescriptorSetManager::Handle &) const
void getZeroSamplerDescriptorSetHandle(GrVkDescriptorSetManager::Handle *handle)
sk_sp< const GrVkPipeline > findOrCreateMSAALoadPipeline(const GrVkRenderPass &renderPass, int numSamples, VkPipelineShaderStageCreateInfo *, VkPipelineLayout)
sk_sp< SkBlender > blender SkRect rect
VkPipelineLayoutCreateFlags flags
uint32_t pushConstantRangeCount
const VkPushConstantRange * pPushConstantRanges
const VkDescriptorSetLayout * pSetLayouts
#define TRACE_EVENT0(category_group, name)
@ VK_SHADER_STAGE_VERTEX_BIT
@ VK_SHADER_STAGE_FRAGMENT_BIT
VkFlags VkPipelineLayoutCreateFlags
@ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO