summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2022-02-24 01:57:18 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2022-02-24 01:57:18 +0000
commitb24b5b9049e889ee4eb39b565bcc8d48bd45ab48 (patch)
tree658ca4e6b41655f49463c85edbaeda48979c394c /lib/mesa/src/gallium/auxiliary/draw
parent57768bbb154c2879d34ec20e401b19472e77aaf7 (diff)
Import Mesa 21.3.7
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/draw')
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_cliptest_tmp.h4
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_decompose_tmp.h22
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_gs.c10
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_gs.h1
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_llvm_sample.c2
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_offset.c4
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_pstipple.c9
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c26
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pt.h5
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch.c5
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_vs.c19
11 files changed, 85 insertions, 22 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_cliptest_tmp.h b/lib/mesa/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
index b7c77bfd8..dceae1fd0 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_cliptest_tmp.h
@@ -26,6 +26,7 @@
**************************************************************************/
#include "util/u_bitcast.h"
+#include <math.h>
static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
struct draw_vertex_info *info,
@@ -182,11 +183,10 @@ static boolean TAG(do_cliptest)( struct pt_post_vs *pvs,
* to NaN to help catch potential errors later.
*/
else {
- float zero = 0.0f;
position[0] =
position[1] =
position[2] =
- position[3] = zero / zero; /* MSVC doesn't accept 0.0 / 0.0 */
+ position[3] = NAN;
}
#endif
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_decompose_tmp.h b/lib/mesa/src/gallium/auxiliary/draw/draw_decompose_tmp.h
index e9f3b1d88..7686afebe 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_decompose_tmp.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_decompose_tmp.h
@@ -170,7 +170,10 @@ FUNC(FUNC_VARS)
idx[1] = GET_ELT(i + 1);
idx[2] = GET_ELT(i + 2);
idx[3] = GET_ELT(i + 3);
-
+#ifdef PASS_QUADS
+ QUAD(0, idx[0], idx[1],
+ idx[2], idx[3]);
+#else
flags = DRAW_PIPE_RESET_STIPPLE |
DRAW_PIPE_EDGE_FLAG_0 |
DRAW_PIPE_EDGE_FLAG_2;
@@ -180,6 +183,7 @@ FUNC(FUNC_VARS)
flags = DRAW_PIPE_EDGE_FLAG_0 |
DRAW_PIPE_EDGE_FLAG_1;
TRIANGLE(flags, idx[1], idx[2], idx[3]);
+#endif
}
}
else {
@@ -188,7 +192,10 @@ FUNC(FUNC_VARS)
idx[1] = GET_ELT(i + 1);
idx[2] = GET_ELT(i + 2);
idx[3] = GET_ELT(i + 3);
-
+#ifdef PASS_QUADS
+ QUAD(0, idx[0], idx[1],
+ idx[2], idx[3]);
+#else
flags = DRAW_PIPE_RESET_STIPPLE |
DRAW_PIPE_EDGE_FLAG_0 |
DRAW_PIPE_EDGE_FLAG_1;
@@ -204,6 +211,7 @@ FUNC(FUNC_VARS)
TRIANGLE(flags, idx[3], idx[1], idx[2]);
else
TRIANGLE(flags, idx[0], idx[2], idx[3]);
+#endif
}
}
break;
@@ -220,6 +228,10 @@ FUNC(FUNC_VARS)
idx[2] = GET_ELT(i + 2);
idx[3] = GET_ELT(i + 3);
+#ifdef PASS_QUADS
+ QUAD(0, idx[2], idx[0],
+ idx[1], idx[3]);
+#else
/* always emit idx[3] last */
flags = DRAW_PIPE_RESET_STIPPLE |
DRAW_PIPE_EDGE_FLAG_0 |
@@ -229,6 +241,7 @@ FUNC(FUNC_VARS)
flags = DRAW_PIPE_EDGE_FLAG_0 |
DRAW_PIPE_EDGE_FLAG_1;
TRIANGLE(flags, idx[0], idx[1], idx[3]);
+#endif
}
}
else {
@@ -238,6 +251,10 @@ FUNC(FUNC_VARS)
idx[2] = GET_ELT(i + 2);
idx[3] = GET_ELT(i + 3);
+#ifdef PASS_QUADS
+ QUAD(0, idx[3], idx[2],
+ idx[0], idx[1]);
+#else
flags = DRAW_PIPE_RESET_STIPPLE |
DRAW_PIPE_EDGE_FLAG_0 |
DRAW_PIPE_EDGE_FLAG_1;
@@ -253,6 +270,7 @@ FUNC(FUNC_VARS)
TRIANGLE(flags, idx[3], idx[0], idx[1]);
else
TRIANGLE(flags, idx[0], idx[1], idx[3]);
+#endif
}
}
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_gs.c b/lib/mesa/src/gallium/auxiliary/draw/draw_gs.c
index ed698e920..90e66b643 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_gs.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_gs.c
@@ -834,12 +834,18 @@ draw_create_geometry_shader(struct draw_context *draw,
gs->primitive_boundary = gs->max_output_vertices + 1;
gs->position_output = -1;
+ bool found_clipvertex = false;
for (i = 0; i < gs->info.num_outputs; i++) {
if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
gs->info.output_semantic_index[i] == 0)
gs->position_output = i;
if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_VIEWPORT_INDEX)
gs->viewport_index_output = i;
+ if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_CLIPVERTEX &&
+ gs->info.output_semantic_index[i] == 0) {
+ found_clipvertex = true;
+ gs->clipvertex_output = i;
+ }
if (gs->info.output_semantic_name[i] == TGSI_SEMANTIC_CLIPDIST) {
debug_assert(gs->info.output_semantic_index[i] <
PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
@@ -847,6 +853,9 @@ draw_create_geometry_shader(struct draw_context *draw,
}
}
+ if (!found_clipvertex)
+ gs->clipvertex_output = gs->position_output;
+
gs->machine = draw->gs.tgsi.machine;
gs->num_vertex_streams = 1;
@@ -900,6 +909,7 @@ void draw_bind_geometry_shader(struct draw_context *draw,
draw->gs.geometry_shader = dgs;
draw->gs.num_gs_outputs = dgs->info.num_outputs;
draw->gs.position_output = dgs->position_output;
+ draw->gs.clipvertex_output = dgs->clipvertex_output;
draw_geometry_shader_prepare(dgs, draw);
}
else {
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_gs.h b/lib/mesa/src/gallium/auxiliary/draw/draw_gs.h
index 9449ec509..10969426f 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_gs.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_gs.h
@@ -75,6 +75,7 @@ struct draw_geometry_shader {
struct tgsi_shader_info info;
unsigned position_output;
unsigned viewport_index_output;
+ unsigned clipvertex_output;
unsigned ccdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];
unsigned max_output_vertices;
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_llvm_sample.c b/lib/mesa/src/gallium/auxiliary/draw/draw_llvm_sample.c
index a3895c798..b3e98be55 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_llvm_sample.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_llvm_sample.c
@@ -289,6 +289,7 @@ DRAW_LLVM_SAMPLER_MEMBER(min_lod, DRAW_JIT_SAMPLER_MIN_LOD, TRUE)
DRAW_LLVM_SAMPLER_MEMBER(max_lod, DRAW_JIT_SAMPLER_MAX_LOD, TRUE)
DRAW_LLVM_SAMPLER_MEMBER(lod_bias, DRAW_JIT_SAMPLER_LOD_BIAS, TRUE)
DRAW_LLVM_SAMPLER_MEMBER(border_color, DRAW_JIT_SAMPLER_BORDER_COLOR, FALSE)
+DRAW_LLVM_SAMPLER_MEMBER(max_aniso, DRAW_JIT_SAMPLER_MAX_ANISO, TRUE)
#define DRAW_LLVM_IMAGE_MEMBER(_name, _index, _emit_load) \
static LLVMValueRef \
@@ -405,6 +406,7 @@ draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_stat
sampler->dynamic_state.base.max_lod = draw_llvm_sampler_max_lod;
sampler->dynamic_state.base.lod_bias = draw_llvm_sampler_lod_bias;
sampler->dynamic_state.base.border_color = draw_llvm_sampler_border_color;
+ sampler->dynamic_state.base.max_aniso = draw_llvm_sampler_max_aniso;
sampler->dynamic_state.static_state = static_state;
sampler->nr_samplers = nr_samplers;
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_offset.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_offset.c
index 08d47f005..87db9cdda 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_offset.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_offset.c
@@ -97,7 +97,7 @@ static void do_offset_tri( struct draw_stage *stage,
if (stage->draw->floating_point_depth) {
float bias;
union fi maxz;
- maxz.f = MAX3(v0[2], v1[2], v2[2]);
+ maxz.f = MAX3(fabs(v0[2]), fabs(v1[2]), fabs(v2[2]));
/* just do the math directly on shifted number */
maxz.ui &= 0xff << 23;
maxz.i -= 23 << 23;
@@ -187,7 +187,7 @@ static void offset_first_tri( struct draw_stage *stage,
if (stage->draw->floating_point_depth) {
offset->units = (float) rast->offset_units;
} else {
- offset->units = (float) (rast->offset_units * stage->draw->mrd);
+ offset->units = (float) (rast->offset_units * stage->draw->mrd * 2);
}
}
else {
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_pstipple.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
index eb7ad8bf2..d5f757eb1 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_pstipple.c
@@ -109,6 +109,7 @@ struct pstip_stage
enum pipe_shader_type shader,
unsigned start, unsigned count,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
struct pipe_sampler_view **);
void (*driver_set_polygon_stipple)(struct pipe_context *,
@@ -224,7 +225,8 @@ pstip_first_tri(struct draw_stage *stage, struct prim_header *header)
num_samplers, pstip->state.samplers);
pstip->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
- num_sampler_views, 0, pstip->state.sampler_views);
+ num_sampler_views, 0, false,
+ pstip->state.sampler_views);
draw->suspend_flushing = FALSE;
@@ -253,7 +255,7 @@ pstip_flush(struct draw_stage *stage, unsigned flags)
pstip->state.samplers);
pstip->driver_set_sampler_views(pipe, PIPE_SHADER_FRAGMENT, 0,
- pstip->num_sampler_views, 0,
+ pstip->num_sampler_views, 0, false,
pstip->state.sampler_views);
draw->suspend_flushing = FALSE;
@@ -418,6 +420,7 @@ pstip_set_sampler_views(struct pipe_context *pipe,
enum pipe_shader_type shader,
unsigned start, unsigned num,
unsigned unbind_num_trailing_slots,
+ bool take_ownership,
struct pipe_sampler_view **views)
{
struct pstip_stage *pstip = pstip_stage_from_pipe(pipe);
@@ -438,7 +441,7 @@ pstip_set_sampler_views(struct pipe_context *pipe,
/* pass-through */
pstip->driver_set_sampler_views(pstip->pipe, shader, start, num,
- unbind_num_trailing_slots, views);
+ unbind_num_trailing_slots, take_ownership, views);
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c b/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c
index e628a143d..9a957f33f 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler.c
@@ -201,6 +201,28 @@ prim_tri(struct draw_assembler *asmblr,
copy_verts(asmblr, indices, 3);
}
+static void
+prim_quad(struct draw_assembler *asmblr,
+ unsigned i0, unsigned i1,
+ unsigned i2, unsigned i3)
+{
+ unsigned indices[4];
+
+ if (asmblr->needs_primid) {
+ inject_primid(asmblr, i0, asmblr->primid);
+ inject_primid(asmblr, i1, asmblr->primid);
+ inject_primid(asmblr, i2, asmblr->primid);
+ inject_primid(asmblr, i3, asmblr->primid++);
+ }
+ indices[0] = i0;
+ indices[1] = i1;
+ indices[2] = i2;
+ indices[3] = i3;
+
+ add_prim(asmblr, 4);
+ copy_verts(asmblr, indices, 4);
+}
+
void
draw_prim_assembler_prepare_outputs(struct draw_assembler *ia)
{
@@ -244,7 +266,9 @@ draw_prim_assembler_run(struct draw_context *draw,
{
struct draw_assembler *asmblr = draw->ia;
unsigned start, i;
- unsigned assembled_prim = u_reduced_prim(input_prims->prim);
+ unsigned assembled_prim = (input_prims->prim == PIPE_PRIM_QUADS ||
+ input_prims->prim == PIPE_PRIM_QUAD_STRIP) ?
+ PIPE_PRIM_QUADS : u_reduced_prim(input_prims->prim);
unsigned max_primitives = u_decomposed_prims_for_vertices(
input_prims->prim, input_prims->count);
unsigned max_verts = u_vertices_per_prim(assembled_prim) * max_primitives;
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pt.h b/lib/mesa/src/gallium/auxiliary/draw/draw_pt.h
index 00527527f..5201676e1 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pt.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pt.h
@@ -147,12 +147,7 @@ struct draw_pt_front_end *draw_pt_vsplit(struct draw_context *draw);
* Currently one general-purpose case which can do all possibilities,
* at the slight expense of creating a vertex_header in some cases
* unecessarily.
- *
- * The special case fetch_emit code avoids pipeline vertices
- * altogether and builds hardware vertices directly from API
- * vertex_elements.
*/
-struct draw_pt_middle_end *draw_pt_fetch_emit( struct draw_context *draw );
struct draw_pt_middle_end *draw_pt_middle_fse( struct draw_context *draw );
struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *draw);
struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit_llvm(struct draw_context *draw);
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch.c
index 17fcfa067..b826b3381 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch.c
@@ -50,11 +50,6 @@ struct pt_fetch {
* Perform the fetch from API vertex elements & vertex buffers, to a
* contiguous set of float[4] attributes as required for the
* vertex_shader->run_linear() method.
- *
- * This is used in all cases except pure passthrough
- * (draw_pt_fetch_emit.c) which has its own version to translate
- * directly to hw vertices.
- *
*/
void
draw_pt_fetch_prepare(struct pt_fetch *fetch,
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_vs.c b/lib/mesa/src/gallium/auxiliary/draw/draw_vs.c
index e8dbc11bc..41e6c7a04 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_vs.c
+++ b/lib/mesa/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,22 @@ 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)) ||
+ (screen->get_shader_param(screen, PIPE_SHADER_VERTEX,
+ PIPE_SHADER_CAP_PREFERRED_IR) ==
+ PIPE_SHADER_IR_TGSI))) {
+ 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)