}
static VkResult
-radv_device_init_meta_blit_color(struct radv_device *device,
- struct radv_shader_module *vs)
+build_pipeline(struct radv_device *device,
+ VkImageAspectFlagBits aspect,
+ enum glsl_sampler_dim tex_dim,
+ unsigned fs_key,
+ VkPipeline *pipeline)
{
- struct radv_shader_module fs_1d = {0}, fs_2d = {0}, fs_3d = {0};
- VkResult result;
+ VkResult result = VK_SUCCESS;
+ struct radv_shader_module fs = {0};
+ struct radv_shader_module vs = {.nir = build_nir_vertex_shader()};
+ VkRenderPass rp;
+
+ switch(aspect) {
+ case VK_IMAGE_ASPECT_COLOR_BIT:
+ fs.nir = build_nir_copy_fragment_shader(tex_dim);
+ rp = device->meta_state.blit.render_pass[fs_key][0];
+ break;
+ case VK_IMAGE_ASPECT_DEPTH_BIT:
+ fs.nir = build_nir_copy_fragment_shader_depth(tex_dim);
+ rp = device->meta_state.blit.depth_only_rp[0];
+ break;
+ case VK_IMAGE_ASPECT_STENCIL_BIT:
+ fs.nir = build_nir_copy_fragment_shader_stencil(tex_dim);
+ rp = device->meta_state.blit.stencil_only_rp[0];
+ break;
+ default:
+ unreachable("Unhandled aspect");
+ }
+ VkPipelineVertexInputStateCreateInfo vi_create_info = {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
+ .vertexBindingDescriptionCount = 0,
+ .vertexAttributeDescriptionCount = 0,
+ };
+
+ VkPipelineShaderStageCreateInfo pipeline_shader_stages[] = {
+ {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
+ .stage = VK_SHADER_STAGE_VERTEX_BIT,
+ .module = radv_shader_module_to_handle(&vs),
+ .pName = "main",
+ .pSpecializationInfo = NULL
+ }, {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
+ .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
+ .module = radv_shader_module_to_handle(&fs),
+ .pName = "main",
+ .pSpecializationInfo = NULL
+ },
+ };
+
+ VkGraphicsPipelineCreateInfo vk_pipeline_info = {
+ .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
+ .stageCount = ARRAY_SIZE(pipeline_shader_stages),
+ .pStages = pipeline_shader_stages,
+ .pVertexInputState = &vi_create_info,
+ .pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
+ .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
+ .primitiveRestartEnable = false,
+ },
+ .pViewportState = &(VkPipelineViewportStateCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
+ .viewportCount = 1,
+ .scissorCount = 1,
+ },
+ .pRasterizationState = &(VkPipelineRasterizationStateCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
+ .rasterizerDiscardEnable = false,
+ .polygonMode = VK_POLYGON_MODE_FILL,
+ .cullMode = VK_CULL_MODE_NONE,
+ .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE
+ },
+ .pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
+ .rasterizationSamples = 1,
+ .sampleShadingEnable = false,
+ .pSampleMask = (VkSampleMask[]) { UINT32_MAX },
+ },
+ .pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
+ .dynamicStateCount = 4,
+ .pDynamicStates = (VkDynamicState[]) {
+ VK_DYNAMIC_STATE_VIEWPORT,
+ VK_DYNAMIC_STATE_SCISSOR,
+ VK_DYNAMIC_STATE_LINE_WIDTH,
+ VK_DYNAMIC_STATE_BLEND_CONSTANTS,
+ },
+ },
+ .flags = 0,
+ .layout = device->meta_state.blit.pipeline_layout,
+ .renderPass = rp,
+ .subpass = 0,
+ };
+
+ switch(aspect) {
+ case VK_IMAGE_ASPECT_COLOR_BIT:
+ vk_pipeline_info.pColorBlendState = &(VkPipelineColorBlendStateCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
+ .attachmentCount = 1,
+ .pAttachments = (VkPipelineColorBlendAttachmentState []) {
+ { .colorWriteMask =
+ VK_COLOR_COMPONENT_A_BIT |
+ VK_COLOR_COMPONENT_R_BIT |
+ VK_COLOR_COMPONENT_G_BIT |
+ VK_COLOR_COMPONENT_B_BIT },
+ }
+ };
+ break;
+ case VK_IMAGE_ASPECT_DEPTH_BIT:
+ vk_pipeline_info.pDepthStencilState = &(VkPipelineDepthStencilStateCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
+ .depthTestEnable = true,
+ .depthWriteEnable = true,
+ .depthCompareOp = VK_COMPARE_OP_ALWAYS,
+ };
+ break;
+ case VK_IMAGE_ASPECT_STENCIL_BIT:
+ vk_pipeline_info.pDepthStencilState = &(VkPipelineDepthStencilStateCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
+ .depthTestEnable = false,
+ .depthWriteEnable = false,
+ .stencilTestEnable = true,
+ .front = {
+ .failOp = VK_STENCIL_OP_REPLACE,
+ .passOp = VK_STENCIL_OP_REPLACE,
+ .depthFailOp = VK_STENCIL_OP_REPLACE,
+ .compareOp = VK_COMPARE_OP_ALWAYS,
+ .compareMask = 0xff,
+ .writeMask = 0xff,
+ .reference = 0
+ },
+ .back = {
+ .failOp = VK_STENCIL_OP_REPLACE,
+ .passOp = VK_STENCIL_OP_REPLACE,
+ .depthFailOp = VK_STENCIL_OP_REPLACE,
+ .compareOp = VK_COMPARE_OP_ALWAYS,
+ .compareMask = 0xff,
+ .writeMask = 0xff,
+ .reference = 0
+ },
+ .depthCompareOp = VK_COMPARE_OP_ALWAYS,
+ };
+ break;
+ default:
+ unreachable("Unhandled aspect");
+ }
- fs_1d.nir = build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_1D);
- fs_2d.nir = build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_2D);
- fs_3d.nir = build_nir_copy_fragment_shader(GLSL_SAMPLER_DIM_3D);
+ const struct radv_graphics_pipeline_create_info radv_pipeline_info = {
+ .use_rectlist = true
+ };
+
+ result = radv_graphics_pipeline_create(radv_device_to_handle(device),
+ radv_pipeline_cache_to_handle(&device->meta_state.cache),
+ &vk_pipeline_info, &radv_pipeline_info,
+ &device->meta_state.alloc, pipeline);
+ ralloc_free(vs.nir);
+ ralloc_free(fs.nir);
+ return result;
+}
+
+static VkResult
+radv_device_init_meta_blit_color(struct radv_device *device)
+{
+ VkResult result;
for (unsigned i = 0; i < NUM_META_FS_KEYS; ++i) {
unsigned key = radv_format_meta_fs_key(radv_fs_key_format_exemplars[i]);
goto fail;
}
- VkPipelineVertexInputStateCreateInfo vi_create_info = {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
- .vertexBindingDescriptionCount = 0,
- .vertexAttributeDescriptionCount = 0,
- };
-
- VkPipelineShaderStageCreateInfo pipeline_shader_stages[] = {
- {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
- .stage = VK_SHADER_STAGE_VERTEX_BIT,
- .module = radv_shader_module_to_handle(vs),
- .pName = "main",
- .pSpecializationInfo = NULL
- }, {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
- .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
- .module = VK_NULL_HANDLE, /* TEMPLATE VALUE! FILL ME IN! */
- .pName = "main",
- .pSpecializationInfo = NULL
- },
- };
-
- const VkGraphicsPipelineCreateInfo vk_pipeline_info = {
- .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
- .stageCount = ARRAY_SIZE(pipeline_shader_stages),
- .pStages = pipeline_shader_stages,
- .pVertexInputState = &vi_create_info,
- .pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
- .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
- .primitiveRestartEnable = false,
- },
- .pViewportState = &(VkPipelineViewportStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
- .viewportCount = 1,
- .scissorCount = 1,
- },
- .pRasterizationState = &(VkPipelineRasterizationStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
- .rasterizerDiscardEnable = false,
- .polygonMode = VK_POLYGON_MODE_FILL,
- .cullMode = VK_CULL_MODE_NONE,
- .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE
- },
- .pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
- .rasterizationSamples = 1,
- .sampleShadingEnable = false,
- .pSampleMask = (VkSampleMask[]) { UINT32_MAX },
- },
- .pColorBlendState = &(VkPipelineColorBlendStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
- .attachmentCount = 1,
- .pAttachments = (VkPipelineColorBlendAttachmentState []) {
- { .colorWriteMask =
- VK_COLOR_COMPONENT_A_BIT |
- VK_COLOR_COMPONENT_R_BIT |
- VK_COLOR_COMPONENT_G_BIT |
- VK_COLOR_COMPONENT_B_BIT },
- }
- },
- .pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
- .dynamicStateCount = 4,
- .pDynamicStates = (VkDynamicState[]) {
- VK_DYNAMIC_STATE_VIEWPORT,
- VK_DYNAMIC_STATE_SCISSOR,
- VK_DYNAMIC_STATE_LINE_WIDTH,
- VK_DYNAMIC_STATE_BLEND_CONSTANTS,
- },
- },
- .flags = 0,
- .layout = device->meta_state.blit.pipeline_layout,
- .renderPass = device->meta_state.blit.render_pass[key][0],
- .subpass = 0,
- };
-
- const struct radv_graphics_pipeline_create_info radv_pipeline_info = {
- .use_rectlist = true
- };
-
- pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_1d);
- result = radv_graphics_pipeline_create(radv_device_to_handle(device),
- radv_pipeline_cache_to_handle(&device->meta_state.cache),
- &vk_pipeline_info, &radv_pipeline_info,
- &device->meta_state.alloc, &device->meta_state.blit.pipeline_1d_src[key]);
+ result = build_pipeline(device, VK_IMAGE_ASPECT_COLOR_BIT, GLSL_SAMPLER_DIM_1D, key, &device->meta_state.blit.pipeline_1d_src[key]);
if (result != VK_SUCCESS)
goto fail;
- pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_2d);
- result = radv_graphics_pipeline_create(radv_device_to_handle(device),
- radv_pipeline_cache_to_handle(&device->meta_state.cache),
- &vk_pipeline_info, &radv_pipeline_info,
- &device->meta_state.alloc, &device->meta_state.blit.pipeline_2d_src[key]);
+ result = build_pipeline(device, VK_IMAGE_ASPECT_COLOR_BIT, GLSL_SAMPLER_DIM_2D, key, &device->meta_state.blit.pipeline_2d_src[key]);
if (result != VK_SUCCESS)
goto fail;
- pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_3d);
- result = radv_graphics_pipeline_create(radv_device_to_handle(device),
- radv_pipeline_cache_to_handle(&device->meta_state.cache),
- &vk_pipeline_info, &radv_pipeline_info,
- &device->meta_state.alloc, &device->meta_state.blit.pipeline_3d_src[key]);
+ result = build_pipeline(device, VK_IMAGE_ASPECT_COLOR_BIT, GLSL_SAMPLER_DIM_3D, key, &device->meta_state.blit.pipeline_3d_src[key]);
if (result != VK_SUCCESS)
goto fail;
result = VK_SUCCESS;
fail:
- ralloc_free(fs_1d.nir);
- ralloc_free(fs_2d.nir);
- ralloc_free(fs_3d.nir);
return result;
}
static VkResult
-radv_device_init_meta_blit_depth(struct radv_device *device,
- struct radv_shader_module *vs)
+radv_device_init_meta_blit_depth(struct radv_device *device)
{
- struct radv_shader_module fs_1d = {0}, fs_2d = {0}, fs_3d = {0};
VkResult result;
- fs_1d.nir = build_nir_copy_fragment_shader_depth(GLSL_SAMPLER_DIM_1D);
- fs_2d.nir = build_nir_copy_fragment_shader_depth(GLSL_SAMPLER_DIM_2D);
- fs_3d.nir = build_nir_copy_fragment_shader_depth(GLSL_SAMPLER_DIM_3D);
-
for (enum radv_blit_ds_layout ds_layout = RADV_BLIT_DS_LAYOUT_TILE_ENABLE; ds_layout < RADV_BLIT_DS_LAYOUT_COUNT; ds_layout++) {
VkImageLayout layout = radv_meta_blit_ds_to_layout(ds_layout);
result = radv_CreateRenderPass(radv_device_to_handle(device),
goto fail;
}
- VkPipelineVertexInputStateCreateInfo vi_create_info = {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
- .vertexBindingDescriptionCount = 0,
- .vertexAttributeDescriptionCount = 0,
- };
-
- VkPipelineShaderStageCreateInfo pipeline_shader_stages[] = {
- {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
- .stage = VK_SHADER_STAGE_VERTEX_BIT,
- .module = radv_shader_module_to_handle(vs),
- .pName = "main",
- .pSpecializationInfo = NULL
- }, {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
- .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
- .module = VK_NULL_HANDLE, /* TEMPLATE VALUE! FILL ME IN! */
- .pName = "main",
- .pSpecializationInfo = NULL
- },
- };
-
- const VkGraphicsPipelineCreateInfo vk_pipeline_info = {
- .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
- .stageCount = ARRAY_SIZE(pipeline_shader_stages),
- .pStages = pipeline_shader_stages,
- .pVertexInputState = &vi_create_info,
- .pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
- .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
- .primitiveRestartEnable = false,
- },
- .pViewportState = &(VkPipelineViewportStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
- .viewportCount = 1,
- .scissorCount = 1,
- },
- .pRasterizationState = &(VkPipelineRasterizationStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
- .rasterizerDiscardEnable = false,
- .polygonMode = VK_POLYGON_MODE_FILL,
- .cullMode = VK_CULL_MODE_NONE,
- .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE
- },
- .pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
- .rasterizationSamples = 1,
- .sampleShadingEnable = false,
- .pSampleMask = (VkSampleMask[]) { UINT32_MAX },
- },
- .pColorBlendState = &(VkPipelineColorBlendStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
- .attachmentCount = 0,
- .pAttachments = NULL,
- },
- .pDepthStencilState = &(VkPipelineDepthStencilStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
- .depthTestEnable = true,
- .depthWriteEnable = true,
- .depthCompareOp = VK_COMPARE_OP_ALWAYS,
- },
- .pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
- .dynamicStateCount = 9,
- .pDynamicStates = (VkDynamicState[]) {
- VK_DYNAMIC_STATE_VIEWPORT,
- VK_DYNAMIC_STATE_SCISSOR,
- VK_DYNAMIC_STATE_LINE_WIDTH,
- VK_DYNAMIC_STATE_DEPTH_BIAS,
- VK_DYNAMIC_STATE_BLEND_CONSTANTS,
- VK_DYNAMIC_STATE_DEPTH_BOUNDS,
- VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK,
- VK_DYNAMIC_STATE_STENCIL_WRITE_MASK,
- VK_DYNAMIC_STATE_STENCIL_REFERENCE,
- },
- },
- .flags = 0,
- .layout = device->meta_state.blit.pipeline_layout,
- .renderPass = device->meta_state.blit.depth_only_rp[0],
- .subpass = 0,
- };
-
- const struct radv_graphics_pipeline_create_info radv_pipeline_info = {
- .use_rectlist = true
- };
-
- pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_1d);
- result = radv_graphics_pipeline_create(radv_device_to_handle(device),
- radv_pipeline_cache_to_handle(&device->meta_state.cache),
- &vk_pipeline_info, &radv_pipeline_info,
- &device->meta_state.alloc, &device->meta_state.blit.depth_only_1d_pipeline);
+ result = build_pipeline(device, VK_IMAGE_ASPECT_DEPTH_BIT, GLSL_SAMPLER_DIM_1D, 0, &device->meta_state.blit.depth_only_1d_pipeline);
if (result != VK_SUCCESS)
goto fail;
- pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_2d);
- result = radv_graphics_pipeline_create(radv_device_to_handle(device),
- radv_pipeline_cache_to_handle(&device->meta_state.cache),
- &vk_pipeline_info, &radv_pipeline_info,
- &device->meta_state.alloc, &device->meta_state.blit.depth_only_2d_pipeline);
+ result = build_pipeline(device, VK_IMAGE_ASPECT_DEPTH_BIT, GLSL_SAMPLER_DIM_2D, 0, &device->meta_state.blit.depth_only_2d_pipeline);
if (result != VK_SUCCESS)
goto fail;
- pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_3d);
- result = radv_graphics_pipeline_create(radv_device_to_handle(device),
- radv_pipeline_cache_to_handle(&device->meta_state.cache),
- &vk_pipeline_info, &radv_pipeline_info,
- &device->meta_state.alloc, &device->meta_state.blit.depth_only_3d_pipeline);
+ result = build_pipeline(device, VK_IMAGE_ASPECT_DEPTH_BIT, GLSL_SAMPLER_DIM_3D, 0, &device->meta_state.blit.depth_only_3d_pipeline);
if (result != VK_SUCCESS)
goto fail;
fail:
- ralloc_free(fs_1d.nir);
- ralloc_free(fs_2d.nir);
- ralloc_free(fs_3d.nir);
return result;
}
static VkResult
-radv_device_init_meta_blit_stencil(struct radv_device *device,
- struct radv_shader_module *vs)
+radv_device_init_meta_blit_stencil(struct radv_device *device)
{
- struct radv_shader_module fs_1d = {0}, fs_2d = {0}, fs_3d = {0};
VkResult result;
- fs_1d.nir = build_nir_copy_fragment_shader_stencil(GLSL_SAMPLER_DIM_1D);
- fs_2d.nir = build_nir_copy_fragment_shader_stencil(GLSL_SAMPLER_DIM_2D);
- fs_3d.nir = build_nir_copy_fragment_shader_stencil(GLSL_SAMPLER_DIM_3D);
-
for (enum radv_blit_ds_layout ds_layout = RADV_BLIT_DS_LAYOUT_TILE_ENABLE; ds_layout < RADV_BLIT_DS_LAYOUT_COUNT; ds_layout++) {
VkImageLayout layout = radv_meta_blit_ds_to_layout(ds_layout);
result = radv_CreateRenderPass(radv_device_to_handle(device),
if (result != VK_SUCCESS)
goto fail;
- VkPipelineVertexInputStateCreateInfo vi_create_info = {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
- .vertexBindingDescriptionCount = 0,
- .vertexAttributeDescriptionCount = 0,
- };
-
- VkPipelineShaderStageCreateInfo pipeline_shader_stages[] = {
- {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
- .stage = VK_SHADER_STAGE_VERTEX_BIT,
- .module = radv_shader_module_to_handle(vs),
- .pName = "main",
- .pSpecializationInfo = NULL
- }, {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
- .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
- .module = VK_NULL_HANDLE, /* TEMPLATE VALUE! FILL ME IN! */
- .pName = "main",
- .pSpecializationInfo = NULL
- },
- };
- const VkGraphicsPipelineCreateInfo vk_pipeline_info = {
- .sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO,
- .stageCount = ARRAY_SIZE(pipeline_shader_stages),
- .pStages = pipeline_shader_stages,
- .pVertexInputState = &vi_create_info,
- .pInputAssemblyState = &(VkPipelineInputAssemblyStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO,
- .topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP,
- .primitiveRestartEnable = false,
- },
- .pViewportState = &(VkPipelineViewportStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO,
- .viewportCount = 1,
- .scissorCount = 1,
- },
- .pRasterizationState = &(VkPipelineRasterizationStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
- .rasterizerDiscardEnable = false,
- .polygonMode = VK_POLYGON_MODE_FILL,
- .cullMode = VK_CULL_MODE_NONE,
- .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE
- },
- .pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
- .rasterizationSamples = 1,
- .sampleShadingEnable = false,
- .pSampleMask = (VkSampleMask[]) { UINT32_MAX },
- },
- .pColorBlendState = &(VkPipelineColorBlendStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
- .attachmentCount = 0,
- .pAttachments = NULL,
- },
- .pDepthStencilState = &(VkPipelineDepthStencilStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO,
- .depthTestEnable = false,
- .depthWriteEnable = false,
- .stencilTestEnable = true,
- .front = {
- .failOp = VK_STENCIL_OP_REPLACE,
- .passOp = VK_STENCIL_OP_REPLACE,
- .depthFailOp = VK_STENCIL_OP_REPLACE,
- .compareOp = VK_COMPARE_OP_ALWAYS,
- .compareMask = 0xff,
- .writeMask = 0xff,
- .reference = 0
- },
- .back = {
- .failOp = VK_STENCIL_OP_REPLACE,
- .passOp = VK_STENCIL_OP_REPLACE,
- .depthFailOp = VK_STENCIL_OP_REPLACE,
- .compareOp = VK_COMPARE_OP_ALWAYS,
- .compareMask = 0xff,
- .writeMask = 0xff,
- .reference = 0
- },
- .depthCompareOp = VK_COMPARE_OP_ALWAYS,
- },
- .pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
- .dynamicStateCount = 6,
- .pDynamicStates = (VkDynamicState[]) {
- VK_DYNAMIC_STATE_VIEWPORT,
- VK_DYNAMIC_STATE_SCISSOR,
- VK_DYNAMIC_STATE_LINE_WIDTH,
- VK_DYNAMIC_STATE_DEPTH_BIAS,
- VK_DYNAMIC_STATE_BLEND_CONSTANTS,
- VK_DYNAMIC_STATE_DEPTH_BOUNDS,
- },
- },
- .flags = 0,
- .layout = device->meta_state.blit.pipeline_layout,
- .renderPass = device->meta_state.blit.stencil_only_rp[0],
- .subpass = 0,
- };
-
- const struct radv_graphics_pipeline_create_info radv_pipeline_info = {
- .use_rectlist = true
- };
-
- pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_1d);
- result = radv_graphics_pipeline_create(radv_device_to_handle(device),
- radv_pipeline_cache_to_handle(&device->meta_state.cache),
- &vk_pipeline_info, &radv_pipeline_info,
- &device->meta_state.alloc, &device->meta_state.blit.stencil_only_1d_pipeline);
+ result = build_pipeline(device, VK_IMAGE_ASPECT_STENCIL_BIT, GLSL_SAMPLER_DIM_1D, 0, &device->meta_state.blit.stencil_only_1d_pipeline);
if (result != VK_SUCCESS)
goto fail;
- pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_2d);
- result = radv_graphics_pipeline_create(radv_device_to_handle(device),
- radv_pipeline_cache_to_handle(&device->meta_state.cache),
- &vk_pipeline_info, &radv_pipeline_info,
- &device->meta_state.alloc, &device->meta_state.blit.stencil_only_2d_pipeline);
+ result = build_pipeline(device, VK_IMAGE_ASPECT_STENCIL_BIT, GLSL_SAMPLER_DIM_2D, 0, &device->meta_state.blit.stencil_only_2d_pipeline);
if (result != VK_SUCCESS)
goto fail;
- pipeline_shader_stages[1].module = radv_shader_module_to_handle(&fs_3d);
- result = radv_graphics_pipeline_create(radv_device_to_handle(device),
- radv_pipeline_cache_to_handle(&device->meta_state.cache),
- &vk_pipeline_info, &radv_pipeline_info,
- &device->meta_state.alloc, &device->meta_state.blit.stencil_only_3d_pipeline);
+ result = build_pipeline(device, VK_IMAGE_ASPECT_STENCIL_BIT, GLSL_SAMPLER_DIM_3D, 0, &device->meta_state.blit.stencil_only_3d_pipeline);
if (result != VK_SUCCESS)
goto fail;
fail:
- ralloc_free(fs_1d.nir);
- ralloc_free(fs_2d.nir);
- ralloc_free(fs_3d.nir);
return result;
}
radv_device_init_meta_blit_state(struct radv_device *device)
{
VkResult result;
- struct radv_shader_module vs = {0};
VkDescriptorSetLayoutCreateInfo ds_layout_info = {
.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO,
if (result != VK_SUCCESS)
goto fail;
- vs.nir = build_nir_vertex_shader();
-
- result = radv_device_init_meta_blit_color(device, &vs);
+ result = radv_device_init_meta_blit_color(device);
if (result != VK_SUCCESS)
goto fail;
- result = radv_device_init_meta_blit_depth(device, &vs);
+ result = radv_device_init_meta_blit_depth(device);
if (result != VK_SUCCESS)
goto fail;
- result = radv_device_init_meta_blit_stencil(device, &vs);
+ result = radv_device_init_meta_blit_stencil(device);
fail:
- ralloc_free(vs.nir);
if (result != VK_SUCCESS)
radv_device_finish_meta_blit_state(device);
return result;