zink: properly handle query pool overflows
[mesa.git] / src / gallium / drivers / zink / zink_state.c
index 814e1e29b6c5dae43c1ab060cad3a451861793c4..bec8d05d5854819c3e2da8fdd4ebbbfd5a441189 100644 (file)
@@ -35,6 +35,7 @@ zink_create_vertex_elements_state(struct pipe_context *pctx,
                                   unsigned num_elements,
                                   const struct pipe_vertex_element *elements)
 {
+   struct zink_screen *screen = zink_screen(pctx->screen);
    unsigned int i;
    struct zink_vertex_elements_state *ves = CALLOC_STRUCT(zink_vertex_elements_state);
    if (!ves)
@@ -62,7 +63,8 @@ zink_create_vertex_elements_state(struct pipe_context *pctx,
 
       ves->hw_state.attribs[i].binding = binding;
       ves->hw_state.attribs[i].location = i; // TODO: unsure
-      ves->hw_state.attribs[i].format = zink_get_format(elem->src_format);
+      ves->hw_state.attribs[i].format = zink_get_format(screen,
+                                                        elem->src_format);
       assert(ves->hw_state.attribs[i].format != VK_FORMAT_UNDEFINED);
       ves->hw_state.attribs[i].offset = elem->src_offset;
    }
@@ -359,7 +361,19 @@ zink_delete_depth_stencil_alpha_state(struct pipe_context *pctx,
 static float
 round_to_granularity(float value, float granularity)
 {
-   return (float)(round(value / granularity) * granularity);
+   return roundf(value / granularity) * granularity;
+}
+
+static float
+line_width(float width, float granularity, const float range[2])
+{
+   assert(granularity >= 0);
+   assert(range[0] <= range[1]);
+
+   if (granularity > 0)
+      width = round_to_granularity(width, granularity);
+
+   return CLAMP(width, range[0], range[1]);
 }
 
 static void *
@@ -395,8 +409,9 @@ zink_create_rasterizer_state(struct pipe_context *pctx,
    state->offset_clamp = rs_state->offset_clamp;
    state->offset_scale = rs_state->offset_scale;
 
-   state->line_width = round_to_granularity(rs_state->line_width,
-                                     screen->props.limits.lineWidthGranularity);
+   state->line_width = line_width(rs_state->line_width,
+                                  screen->props.limits.lineWidthGranularity,
+                                  screen->props.limits.lineWidthRange);
 
    return state;
 }
@@ -406,7 +421,11 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
 {
    struct zink_context *ctx = zink_context(pctx);
    ctx->rast_state = cso;
-   ctx->gfx_pipeline_state.rast_state = &ctx->rast_state->hw_state;
+
+   if (ctx->rast_state) {
+      ctx->gfx_pipeline_state.rast_state = &ctx->rast_state->hw_state;
+      ctx->line_width = ctx->rast_state->line_width;
+   }
 }
 
 static void