From b5e782f5f43185076acbbea1e42000fd1fb48aa0 Mon Sep 17 00:00:00 2001 From: Neha Bhende Date: Wed, 14 Jul 2021 17:25:48 -0700 Subject: [PATCH] aux/draw: use nir_to_tgsi for draw shader in llvm path Some drivers doesn't support PIPE_SHADER_CAP_INTEGERS. This leads to using load_ubo_vec4 which throws llvmpipe off the guard since it doesn't expect load_ubo_vec4 in shader. Use nir_to_tgsi utility in such a case. This fixes crash seen with conform's mustpass.c, select.c and feedback.c. Also, few gl-select related piglit tests exhibit same crash. Found in vmware's internal testing Reviewed-by: Charmaine Lee Reviewed-by: Emma Anholt v2: incorporated Emma's comments. Added check for PIPE_SHADER_CAP_INTEGERS and remove PIPE_SHADER_IR_TGSI check v3: As per Emma's comment, removed expected crashes for i915 piglit v4: update expetcted passes Part-of: --- src/gallium/auxiliary/draw/draw_vs.c | 16 ++++++++++++++-- .../drivers/i915/ci/piglit-i915-g33-fails.txt | 12 ------------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c index e8dbc11bca6..20ecc2f1696 100644 --- a/src/gallium/auxiliary/draw/draw_vs.c +++ b/src/gallium/auxiliary/draw/draw_vs.c @@ -35,6 +35,8 @@ #include "util/u_memory.h" #include "pipe/p_shader_tokens.h" +#include "pipe/p_context.h" +#include "pipe/p_screen.h" #include "draw_private.h" #include "draw_context.h" @@ -46,6 +48,8 @@ #include "tgsi/tgsi_dump.h" #include "tgsi/tgsi_exec.h" +#include "nir/nir_to_tgsi.h" + DEBUG_GET_ONCE_BOOL_OPTION(gallium_dump_vs, "GALLIUM_DUMP_VS", FALSE) @@ -54,6 +58,7 @@ draw_create_vertex_shader(struct draw_context *draw, const struct pipe_shader_state *shader) { struct draw_vertex_shader *vs = NULL; + struct pipe_shader_state state = *shader; if (draw->dump_vs) { tgsi_dump(shader->tokens, 0); @@ -61,12 +66,19 @@ draw_create_vertex_shader(struct draw_context *draw, #ifdef DRAW_LLVM_AVAILABLE if (draw->pt.middle.llvm) { - vs = draw_create_vs_llvm(draw, shader); + struct pipe_screen *screen = draw->pipe->screen; + if (shader->type == PIPE_SHADER_IR_NIR && + (!screen->get_shader_param(screen, PIPE_SHADER_VERTEX, + PIPE_SHADER_CAP_INTEGERS))) { + state.type = PIPE_SHADER_IR_TGSI; + state.tokens = nir_to_tgsi(shader->ir.nir, screen); + } + vs = draw_create_vs_llvm(draw, &state); } #endif if (!vs) { - vs = draw_create_vs_exec( draw, shader ); + vs = draw_create_vs_exec( draw, &state ); } if (vs) diff --git a/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt b/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt index 50d0e79b086..c33825b7fac 100644 --- a/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt +++ b/src/gallium/drivers/i915/ci/piglit-i915-g33-fails.txt @@ -20,16 +20,9 @@ spec@!opengl 1.0@gl-1.0-drawbuffer-modes,Fail spec@!opengl 1.0@gl-1.0-long-line-loop,Crash spec@!opengl 1.0@gl-1.0-no-op-paths,Fail spec@!opengl 1.0@gl-1.0-ortho-pos,Crash -spec@!opengl 1.0@gl-1.0-rendermode-feedback,Crash spec@!opengl 1.0@gl-1.0-scissor-offscreen,Fail spec@!opengl 1.0@gl-1.0-swapbuffers-behavior,Fail -# mesa/st draw path doesn't do nir-to-tgsi, so gallivm NIR fails -# to handle our vector-y, non-native-integers shaders. We could extend -# gallivm NIR to handle it, or disentangle per-stage native integers on the -# frontend. -spec@!opengl 1.0@rasterpos,Crash - spec@!opengl 1.1@clipflat,Fail spec@!opengl 1.1@clipflat@glBegin/End(GL_TRIANGLE_FAN)- glFrontFace(GL_CCW)- glPolygonMode(GL_FILL)- quadrant: center middle PV: FIRST,Fail spec@!opengl 1.1@clipflat@glBegin/End(GL_TRIANGLE_FAN)- glFrontFace(GL_CW)- glPolygonMode(GL_FILL)- quadrant: center middle PV: FIRST,Fail @@ -54,11 +47,6 @@ spec@!opengl 1.1@getteximage-formats,Crash spec@!opengl 1.1@gl-1.1-drawarrays-vertex-count 100000 varray gl_quad_strip,Crash spec@!opengl 1.1@gl-1.1-drawarrays-vertex-count 100000 vbo gl_quad_strip,Crash spec@!opengl 1.1@gl-1.2-texture-base-level,Fail -spec@!opengl 1.1@gl_select - alpha-test enabled,Crash -spec@!opengl 1.1@gl_select - depth-test enabled,Crash -spec@!opengl 1.1@gl_select - no test function,Crash -spec@!opengl 1.1@gl_select - scissor-test enabled,Crash -spec@!opengl 1.1@gl_select - stencil-test enabled,Crash spec@!opengl 1.1@line-flat-clip-color,Fail spec@!opengl 1.1@linestipple,Fail spec@!opengl 1.1@linestipple@Factor 2x,Fail