zink: use helper function to handle uvec/bvec types
[mesa.git] / src / gallium / drivers / zink / zink_pipeline.c
index b06f02a2e9270530df2589c84cc3aa26bf31214a..261bdde5201a8141cfeba11edd52fa36a2c3d5af 100644 (file)
 #include "util/u_prim.h"
 
 VkPipeline
-zink_create_gfx_pipeline(VkDevice dev, struct zink_gfx_program *prog,
-                         struct zink_gfx_pipeline_state *state)
+zink_create_gfx_pipeline(struct zink_screen *screen,
+                         struct zink_gfx_program *prog,
+                         struct zink_gfx_pipeline_state *state,
+                         VkPrimitiveTopology primitive_topology)
 {
    VkPipelineVertexInputStateCreateInfo vertex_input_state = {};
    vertex_input_state.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
@@ -46,7 +48,7 @@ zink_create_gfx_pipeline(VkDevice dev, struct zink_gfx_program *prog,
 
    VkPipelineInputAssemblyStateCreateInfo primitive_state = {};
    primitive_state.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
-   primitive_state.topology = state->primitive_topology;
+   primitive_state.topology = primitive_topology;
    primitive_state.primitiveRestartEnable = VK_FALSE;
 
    VkPipelineColorBlendStateCreateInfo blend_state = {};
@@ -58,9 +60,10 @@ zink_create_gfx_pipeline(VkDevice dev, struct zink_gfx_program *prog,
 
    VkPipelineMultisampleStateCreateInfo ms_state = {};
    ms_state.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
-   ms_state.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
+   ms_state.rasterizationSamples = state->rast_samples;
    ms_state.alphaToCoverageEnable = state->blend_state->alpha_to_coverage;
    ms_state.alphaToOneEnable = state->blend_state->alpha_to_one;
+   ms_state.pSampleMask = state->sample_mask ? &state->sample_mask : NULL;
 
    VkPipelineViewportStateCreateInfo viewport_state = {};
    viewport_state.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
@@ -82,7 +85,7 @@ zink_create_gfx_pipeline(VkDevice dev, struct zink_gfx_program *prog,
    rast_state.depthBiasConstantFactor = 0.0;
    rast_state.depthBiasClamp = 0.0;
    rast_state.depthBiasSlopeFactor = 0.0;
-   rast_state.lineWidth = state->line_width;
+   rast_state.lineWidth = 1.0f;
 
    VkPipelineDepthStencilStateCreateInfo depth_stencil_state = {};
    depth_stencil_state.sType = VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO;
@@ -97,11 +100,12 @@ zink_create_gfx_pipeline(VkDevice dev, struct zink_gfx_program *prog,
    depth_stencil_state.depthWriteEnable = state->depth_stencil_alpha_state->depth_write;
 
    VkDynamicState dynamicStateEnables[] = {
-      VK_DYNAMIC_STATE_DEPTH_BIAS,
-      VK_DYNAMIC_STATE_SCISSOR,
-      VK_DYNAMIC_STATE_STENCIL_REFERENCE,
       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_STENCIL_REFERENCE,
    };
 
    VkPipelineDynamicStateCreateInfo pipelineDynamicStateCreateInfo = {};
@@ -142,7 +146,8 @@ zink_create_gfx_pipeline(VkDevice dev, struct zink_gfx_program *prog,
    pci.stageCount = num_stages;
 
    VkPipeline pipeline;
-   if (vkCreateGraphicsPipelines(dev, VK_NULL_HANDLE, 1, &pci, NULL, &pipeline) != VK_SUCCESS) {
+   if (vkCreateGraphicsPipelines(screen->dev, VK_NULL_HANDLE, 1, &pci,
+                                 NULL, &pipeline) != VK_SUCCESS) {
       debug_printf("vkCreateGraphicsPipelines failed\n");
       return VK_NULL_HANDLE;
    }