diff --git a/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp b/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp index 9cab71dc4d82389e3ea6771d3df98f7adabc7fb0..d2b621caa836abc95b889f3846c28992a1ee0f3c 100644 --- a/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp +++ b/src/gallium/drivers/d3d12/d3d12_pipeline_state.cpp @@ -126,18 +126,26 @@ fill_so_declaration(const struct pipe_stream_output_info *info, static bool depth_bias(struct d3d12_rasterizer_state *state, enum pipe_prim_type reduced_prim) { - switch (reduced_prim) { - case PIPE_PRIM_POINTS: - return state->base.offset_point; + /* glPolygonOffset is supposed to be only enabled when rendering polygons. + * In d3d12 case, all polygons (and quads) are lowered to triangles */ + if (reduced_prim != PIPE_PRIM_TRIANGLES) + return false; - case PIPE_PRIM_LINES: - return state->base.offset_line; + unsigned fill_mode = state->base.cull_face == PIPE_FACE_FRONT ? state->base.fill_back + : state->base.fill_front; - case PIPE_PRIM_TRIANGLES: + switch (fill_mode) { + case PIPE_POLYGON_MODE_FILL: return state->base.offset_tri; + case PIPE_POLYGON_MODE_LINE: + return state->base.offset_line; + + case PIPE_POLYGON_MODE_POINT: + return state->base.offset_point; + default: - unreachable("unexpected reduced prim"); + unreachable("unexpected fill mode"); } }