summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/auxiliary/draw
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2024-04-02 10:42:24 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2024-04-02 10:42:24 +0000
commita3f73acb9d2cdc62692af7ff93c51f910dff2d0d (patch)
tree303d205e8e6ed9676bdcbe006a402c23bf668f6c /lib/mesa/src/gallium/auxiliary/draw
parentf54e142455cb3c9d1662dae7e096a32a47e5409b (diff)
Merge Mesa 23.3.6
Diffstat (limited to 'lib/mesa/src/gallium/auxiliary/draw')
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_context.c201
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_context.h83
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_gs_tmp.h10
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_llvm.c1011
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_llvm.h397
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_llvm_sample.c309
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_aaline.c52
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_aapoint.c60
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_clip.c82
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_flatshade.c12
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_stipple.c12
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_user_cull.c14
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_validate.c70
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_vbuf.c34
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_wide_line.c10
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pipe_wide_point.c18
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler_tmp.h6
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_private.h230
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pt.c94
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c172
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pt_vsplit.c68
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_pt_vsplit_tmp.h48
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_so_emit_tmp.h16
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_tess.c46
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_tess.h16
-rw-r--r--lib/mesa/src/gallium/auxiliary/draw/draw_vs_exec.c7
26 files changed, 1019 insertions, 2059 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_context.c b/lib/mesa/src/gallium/auxiliary/draw/draw_context.c
index 81ceefc32..d2a37e5ad 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_context.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_context.c
@@ -44,6 +44,7 @@
#include "draw_vs.h"
#include "draw_gs.h"
#include "draw_tess.h"
+#include "draw_mesh.h"
#ifdef DRAW_LLVM_AVAILABLE
#include "gallivm/lp_bld_init.h"
@@ -52,13 +53,13 @@
#endif
-boolean
+bool
draw_get_option_use_llvm(void)
{
#ifdef DRAW_LLVM_AVAILABLE
- return debug_get_bool_option("DRAW_USE_LLVM", TRUE);
+ return debug_get_bool_option("DRAW_USE_LLVM", true);
#else
- return FALSE;
+ return false;
#endif
}
@@ -68,7 +69,7 @@ draw_get_option_use_llvm(void)
*/
static struct draw_context *
draw_create_context(struct pipe_context *pipe, void *context,
- boolean try_llvm)
+ bool try_llvm)
{
struct draw_context *draw = CALLOC_STRUCT(draw_context);
if (!draw)
@@ -105,7 +106,7 @@ err_out:
struct draw_context *
draw_create(struct pipe_context *pipe)
{
- return draw_create_context(pipe, NULL, TRUE);
+ return draw_create_context(pipe, NULL, true);
}
@@ -114,7 +115,7 @@ struct draw_context *
draw_create_with_llvm_context(struct pipe_context *pipe,
void *context)
{
- return draw_create_context(pipe, context, TRUE);
+ return draw_create_context(pipe, context, true);
}
#endif
@@ -125,11 +126,11 @@ draw_create_with_llvm_context(struct pipe_context *pipe,
struct draw_context *
draw_create_no_llvm(struct pipe_context *pipe)
{
- return draw_create_context(pipe, NULL, FALSE);
+ return draw_create_context(pipe, NULL, false);
}
-boolean
+bool
draw_init(struct draw_context *draw)
{
/*
@@ -144,30 +145,30 @@ draw_init(struct draw_context *draw)
ASSIGN_4V(draw->plane[3], 0, 1, 0, 1);
ASSIGN_4V(draw->plane[4], 0, 0, 1, 1); /* yes these are correct */
ASSIGN_4V(draw->plane[5], 0, 0, -1, 1); /* mesa's a bit wonky */
- draw->clip_xy = TRUE;
- draw->clip_z = TRUE;
+ draw->clip_xy = true;
+ draw->clip_z = true;
draw->pt.user.planes = (float (*) [DRAW_TOTAL_CLIP_PLANES][4]) &(draw->plane[0]);
draw->pt.user.eltMax = ~0;
if (!draw_pipeline_init(draw))
- return FALSE;
+ return false;
if (!draw_pt_init(draw))
- return FALSE;
+ return false;
if (!draw_vs_init(draw))
- return FALSE;
+ return false;
if (!draw_gs_init(draw))
- return FALSE;
+ return false;
draw->quads_always_flatshade_last = !draw->pipe->screen->get_param(
draw->pipe->screen, PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION);
draw->floating_point_depth = false;
- return TRUE;
+ return true;
}
@@ -282,10 +283,10 @@ draw_update_clip_flags(struct draw_context *draw)
draw->clip_user = draw->rasterizer &&
draw->rasterizer->clip_plane_enable != 0 &&
!window_space;
- draw->guard_band_points_xy = draw->guard_band_xy ||
- (draw->driver.bypass_clip_points &&
+ draw->guard_band_points_lines_xy = draw->guard_band_xy ||
+ (draw->driver.bypass_clip_points_lines &&
(draw->rasterizer &&
- draw->rasterizer->point_tri_clip));
+ draw->rasterizer->point_line_tri_clip));
}
@@ -322,24 +323,24 @@ void draw_set_rasterizer_state(struct draw_context *draw,
* Some hardware can turn off clipping altogether - in particular any
* hardware with a TNL unit can do its own clipping, even if it is
* relying on the draw module for some other reason.
- * Setting bypass_clip_points to achieve d3d-style point clipping (the driver
+ * Setting bypass_clip_points_lines to achieve d3d-style point clipping (the driver
* will need to do the "vp scissoring") _requires_ the driver to implement
* wide points / point sprites itself (points will still be clipped if rasterizer
- * point_tri_clip isn't set). Only relevant if bypass_clip_xy isn't set.
+ * point_line_tri_clip isn't set). Only relevant if bypass_clip_xy isn't set.
*/
void
draw_set_driver_clipping(struct draw_context *draw,
- boolean bypass_clip_xy,
- boolean bypass_clip_z,
- boolean guard_band_xy,
- boolean bypass_clip_points)
+ bool bypass_clip_xy,
+ bool bypass_clip_z,
+ bool guard_band_xy,
+ bool bypass_clip_points_lines)
{
draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
draw->driver.bypass_clip_xy = bypass_clip_xy;
draw->driver.bypass_clip_z = bypass_clip_z;
draw->driver.guard_band_xy = guard_band_xy;
- draw->driver.bypass_clip_points = bypass_clip_points;
+ draw->driver.bypass_clip_points_lines = bypass_clip_points_lines;
draw_update_clip_flags(draw);
}
@@ -403,15 +404,15 @@ draw_set_viewport_states(struct draw_context *draw,
void
draw_set_vertex_buffers(struct draw_context *draw,
- unsigned start_slot, unsigned count,
+ unsigned count,
unsigned unbind_num_trailing_slots,
const struct pipe_vertex_buffer *buffers)
{
- assert(start_slot + count <= PIPE_MAX_ATTRIBS);
+ assert(count <= PIPE_MAX_ATTRIBS);
util_set_vertex_buffers_count(draw->pt.vertex_buffer,
&draw->pt.nr_vertex_buffers,
- buffers, start_slot, count,
+ buffers, count,
unbind_num_trailing_slots, false);
}
@@ -429,6 +430,8 @@ draw_set_vertex_elements(struct draw_context *draw,
memcpy(draw->pt.vertex_element, elements, count * sizeof(elements[0]));
draw->pt.nr_vertex_elements = count;
+ for (unsigned i = 0; i < count; i++)
+ draw->pt.vertex_strides[elements[i].vertex_buffer_index] = elements[i].src_stride;
}
@@ -460,26 +463,8 @@ draw_set_mapped_constant_buffer(struct draw_context *draw,
draw_do_flush(draw, DRAW_FLUSH_PARAMETER_CHANGE);
- switch (shader_type) {
- case PIPE_SHADER_VERTEX:
- draw->pt.user.vs_constants[slot] = buffer;
- draw->pt.user.vs_constants_size[slot] = size;
- break;
- case PIPE_SHADER_GEOMETRY:
- draw->pt.user.gs_constants[slot] = buffer;
- draw->pt.user.gs_constants_size[slot] = size;
- break;
- case PIPE_SHADER_TESS_CTRL:
- draw->pt.user.tcs_constants[slot] = buffer;
- draw->pt.user.tcs_constants_size[slot] = size;
- break;
- case PIPE_SHADER_TESS_EVAL:
- draw->pt.user.tes_constants[slot] = buffer;
- draw->pt.user.tes_constants_size[slot] = size;
- break;
- default:
- assert(0 && "invalid shader type in draw_set_mapped_constant_buffer");
- }
+ draw->pt.user.constants[shader_type][slot].ptr = buffer;
+ draw->pt.user.constants[shader_type][slot].size = size;
}
void
@@ -497,26 +482,8 @@ draw_set_mapped_shader_buffer(struct draw_context *draw,
draw_do_flush(draw, DRAW_FLUSH_PARAMETER_CHANGE);
- switch (shader_type) {
- case PIPE_SHADER_VERTEX:
- draw->pt.user.vs_ssbos[slot] = buffer;
- draw->pt.user.vs_ssbos_size[slot] = size;
- break;
- case PIPE_SHADER_GEOMETRY:
- draw->pt.user.gs_ssbos[slot] = buffer;
- draw->pt.user.gs_ssbos_size[slot] = size;
- break;
- case PIPE_SHADER_TESS_CTRL:
- draw->pt.user.tcs_ssbos[slot] = buffer;
- draw->pt.user.tcs_ssbos_size[slot] = size;
- break;
- case PIPE_SHADER_TESS_EVAL:
- draw->pt.user.tes_ssbos[slot] = buffer;
- draw->pt.user.tes_ssbos_size[slot] = size;
- break;
- default:
- assert(0 && "invalid shader type in draw_set_mapped_shader_buffer");
- }
+ draw->pt.user.ssbos[shader_type][slot].ptr = buffer;
+ draw->pt.user.ssbos[shader_type][slot].size = size;
}
@@ -536,7 +503,7 @@ draw_wide_point_threshold(struct draw_context *draw, float threshold)
* Should the draw module handle point->quad conversion for drawing sprites?
*/
void
-draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite)
+draw_wide_point_sprites(struct draw_context *draw, bool draw_sprite)
{
draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
draw->pipeline.wide_point_sprites = draw_sprite;
@@ -559,7 +526,7 @@ draw_wide_line_threshold(struct draw_context *draw, float threshold)
* Tells the draw module whether or not to implement line stipple.
*/
void
-draw_enable_line_stipple(struct draw_context *draw, boolean enable)
+draw_enable_line_stipple(struct draw_context *draw, bool enable)
{
draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
draw->pipeline.line_stipple = enable;
@@ -570,7 +537,7 @@ draw_enable_line_stipple(struct draw_context *draw, boolean enable)
* Tells draw module whether to convert points to quads for sprite mode.
*/
void
-draw_enable_point_sprites(struct draw_context *draw, boolean enable)
+draw_enable_point_sprites(struct draw_context *draw, bool enable)
{
draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
draw->pipeline.point_sprite = enable;
@@ -587,15 +554,16 @@ draw_enable_point_sprites(struct draw_context *draw, boolean enable)
*/
int
draw_alloc_extra_vertex_attrib(struct draw_context *draw,
- uint semantic_name, uint semantic_index)
+ enum tgsi_semantic semantic_name,
+ unsigned semantic_index)
{
int slot = draw_find_shader_output(draw, semantic_name, semantic_index);
if (slot >= 0) {
return slot;
}
- uint num_outputs = draw_current_shader_outputs(draw);
- uint n = draw->extra_shader_outputs.num;
+ unsigned num_outputs = draw_current_shader_outputs(draw);
+ unsigned n = draw->extra_shader_outputs.num;
assert(n < ARRAY_SIZE(draw->extra_shader_outputs.semantic_name));
@@ -626,7 +594,9 @@ draw_remove_extra_vertex_attribs(struct draw_context *draw)
struct tgsi_shader_info *
draw_get_shader_info(const struct draw_context *draw)
{
- if (draw->gs.geometry_shader) {
+ if (draw->ms.mesh_shader) {
+ return &draw->ms.mesh_shader->info;
+ } else if (draw->gs.geometry_shader) {
return &draw->gs.geometry_shader->info;
} else if (draw->tes.tess_eval_shader) {
return &draw->tes.tess_eval_shader->info;
@@ -678,7 +648,8 @@ draw_prepare_shader_outputs(struct draw_context *draw)
*/
int
draw_find_shader_output(const struct draw_context *draw,
- uint semantic_name, uint semantic_index)
+ enum tgsi_semantic semantic_name,
+ unsigned semantic_index)
{
const struct tgsi_shader_info *info = draw_get_shader_info(draw);
@@ -709,7 +680,7 @@ draw_find_shader_output(const struct draw_context *draw,
* If geometry shader is present, its output will be returned,
* if not vertex shader is used.
*/
-uint
+unsigned
draw_num_shader_outputs(const struct draw_context *draw)
{
const struct tgsi_shader_info *info = draw_get_shader_info(draw);
@@ -723,7 +694,7 @@ draw_num_shader_outputs(const struct draw_context *draw)
* be filled in by some draw stages (such as AA point, AA line,
* front face).
*/
-uint
+unsigned
draw_total_vs_outputs(const struct draw_context *draw)
{
const struct tgsi_shader_info *info = &draw->vs.vertex_shader->info;
@@ -738,7 +709,7 @@ draw_total_vs_outputs(const struct draw_context *draw)
* be filled in by some draw stages (such as AA point, AA line, front
* face).
*/
-uint
+unsigned
draw_total_gs_outputs(const struct draw_context *draw)
{
if (!draw->gs.geometry_shader)
@@ -751,7 +722,7 @@ draw_total_gs_outputs(const struct draw_context *draw)
/**
* Return total number of the tess ctrl shader outputs.
*/
-uint
+unsigned
draw_total_tcs_outputs(const struct draw_context *draw)
{
if (!draw->tcs.tess_ctrl_shader)
@@ -764,7 +735,7 @@ draw_total_tcs_outputs(const struct draw_context *draw)
/**
* Return total number of the tess eval shader outputs.
*/
-uint
+unsigned
draw_total_tes_outputs(const struct draw_context *draw)
{
if (!draw->tes.tess_eval_shader)
@@ -791,12 +762,6 @@ draw_texture_sampler(struct draw_context *draw,
case PIPE_SHADER_GEOMETRY:
draw->gs.tgsi.sampler = sampler;
break;
- case PIPE_SHADER_TESS_CTRL:
- draw->tcs.tgsi.sampler = sampler;
- break;
- case PIPE_SHADER_TESS_EVAL:
- draw->tes.tgsi.sampler = sampler;
- break;
default:
assert(0);
break;
@@ -821,12 +786,6 @@ draw_image(struct draw_context *draw,
case PIPE_SHADER_GEOMETRY:
draw->gs.tgsi.image = image;
break;
- case PIPE_SHADER_TESS_CTRL:
- draw->tcs.tgsi.image = image;
- break;
- case PIPE_SHADER_TESS_EVAL:
- draw->tes.tgsi.image = image;
- break;
default:
assert(0);
break;
@@ -851,12 +810,6 @@ draw_buffer(struct draw_context *draw,
case PIPE_SHADER_GEOMETRY:
draw->gs.tgsi.buffer = buffer;
break;
- case PIPE_SHADER_TESS_CTRL:
- draw->tcs.tgsi.buffer = buffer;
- break;
- case PIPE_SHADER_TESS_EVAL:
- draw->tes.tgsi.buffer = buffer;
- break;
default:
assert(0);
break;
@@ -901,13 +854,13 @@ void draw_do_flush(struct draw_context *draw, unsigned flags)
if (!draw->suspend_flushing) {
assert(!draw->flushing); /* catch inadvertant recursion */
- draw->flushing = TRUE;
+ draw->flushing = true;
draw_pipeline_flush(draw, flags);
draw_pt_flush(draw, flags);
- draw->flushing = FALSE;
+ draw->flushing = false;
}
}
@@ -918,9 +871,11 @@ void draw_do_flush(struct draw_context *draw, unsigned flags)
* outputs from the vertex shader.
* \sa draw_num_shader_outputs
*/
-uint
+unsigned
draw_current_shader_outputs(const struct draw_context *draw)
{
+ if (draw->ms.mesh_shader)
+ return draw->ms.num_ms_outputs;
if (draw->gs.geometry_shader)
return draw->gs.num_gs_outputs;
if (draw->tes.tess_eval_shader)
@@ -933,9 +888,11 @@ draw_current_shader_outputs(const struct draw_context *draw)
* Return the index of the shader output which will contain the
* vertex position.
*/
-uint
+unsigned
draw_current_shader_position_output(const struct draw_context *draw)
{
+ if (draw->ms.mesh_shader)
+ return draw->ms.position_output;
if (draw->gs.geometry_shader)
return draw->gs.position_output;
if (draw->tes.tess_eval_shader)
@@ -948,9 +905,11 @@ draw_current_shader_position_output(const struct draw_context *draw)
* Return the index of the shader output which will contain the
* viewport index.
*/
-uint
+unsigned
draw_current_shader_viewport_index_output(const struct draw_context *draw)
{
+ if (draw->ms.mesh_shader)
+ return draw->ms.mesh_shader->viewport_index_output;
if (draw->gs.geometry_shader)
return draw->gs.geometry_shader->viewport_index_output;
else if (draw->tes.tess_eval_shader)
@@ -963,9 +922,11 @@ draw_current_shader_viewport_index_output(const struct draw_context *draw)
* Returns true if there's a geometry shader bound and the geometry
* shader writes out a viewport index.
*/
-boolean
+bool
draw_current_shader_uses_viewport_index(const struct draw_context *draw)
{
+ if (draw->ms.mesh_shader)
+ return draw->ms.mesh_shader->info.writes_viewport_index;
if (draw->gs.geometry_shader)
return draw->gs.geometry_shader->info.writes_viewport_index;
else if (draw->tes.tess_eval_shader)
@@ -980,9 +941,11 @@ draw_current_shader_uses_viewport_index(const struct draw_context *draw)
* Note we don't support clipvertex output in the gs. For clipping
* to work correctly hence we return ordinary position output instead.
*/
-uint
+unsigned
draw_current_shader_clipvertex_output(const struct draw_context *draw)
{
+ if (draw->ms.mesh_shader)
+ return draw->ms.clipvertex_output;
if (draw->gs.geometry_shader)
return draw->gs.clipvertex_output;
if (draw->tes.tess_eval_shader)
@@ -991,10 +954,12 @@ draw_current_shader_clipvertex_output(const struct draw_context *draw)
}
-uint
+unsigned
draw_current_shader_ccdistance_output(const struct draw_context *draw, int index)
{
assert(index < PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT);
+ if (draw->ms.mesh_shader)
+ return draw->ms.mesh_shader->ccdistance_output[index];
if (draw->gs.geometry_shader)
return draw->gs.geometry_shader->ccdistance_output[index];
if (draw->tes.tess_eval_shader)
@@ -1003,9 +968,11 @@ draw_current_shader_ccdistance_output(const struct draw_context *draw, int index
}
-uint
+unsigned
draw_current_shader_num_written_clipdistances(const struct draw_context *draw)
{
+ if (draw->ms.mesh_shader)
+ return draw->ms.mesh_shader->info.num_written_clipdistance;
if (draw->gs.geometry_shader)
return draw->gs.geometry_shader->info.num_written_clipdistance;
if (draw->tes.tess_eval_shader)
@@ -1013,9 +980,11 @@ draw_current_shader_num_written_clipdistances(const struct draw_context *draw)
return draw->vs.vertex_shader->info.num_written_clipdistance;
}
-uint
+unsigned
draw_current_shader_num_written_culldistances(const struct draw_context *draw)
{
+ if (draw->ms.mesh_shader)
+ return draw->ms.mesh_shader->info.num_written_culldistance;
if (draw->gs.geometry_shader)
return draw->gs.geometry_shader->info.num_written_culldistance;
if (draw->tes.tess_eval_shader)
@@ -1082,7 +1051,7 @@ draw_set_sampler_views(struct draw_context *draw,
struct pipe_sampler_view **views,
unsigned num)
{
- assert(shader_stage < PIPE_SHADER_TYPES);
+ assert(shader_stage < DRAW_MAX_SHADER_STAGE);
assert(num <= PIPE_MAX_SHADER_SAMPLER_VIEWS);
draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
@@ -1102,7 +1071,7 @@ draw_set_samplers(struct draw_context *draw,
struct pipe_sampler_state **samplers,
unsigned num)
{
- assert(shader_stage < PIPE_SHADER_TYPES);
+ assert(shader_stage < DRAW_MAX_SHADER_STAGE);
assert(num <= PIPE_MAX_SAMPLERS);
draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
@@ -1127,7 +1096,7 @@ draw_set_images(struct draw_context *draw,
struct pipe_image_view *views,
unsigned num)
{
- assert(shader_stage < PIPE_SHADER_TYPES);
+ assert(shader_stage < DRAW_MAX_SHADER_STAGE);
assert(num <= PIPE_MAX_SHADER_IMAGES);
draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
@@ -1247,7 +1216,7 @@ draw_get_shader_param(enum pipe_shader_type shader, enum pipe_shader_cap param)
*/
void
draw_collect_pipeline_statistics(struct draw_context *draw,
- boolean enable)
+ bool enable)
{
draw->collect_statistics = enable;
}
@@ -1295,14 +1264,14 @@ draw_stats_clipper_primitives(struct draw_context *draw,
* outputs. This is done to preserve the front-facing
* info when decomposing primitives into wireframes.
*/
-boolean
+bool
draw_will_inject_frontface(const struct draw_context *draw)
{
unsigned reduced_prim = u_reduced_prim(draw->pt.prim);
const struct pipe_rasterizer_state *rast = draw->rasterizer;
- if (reduced_prim != PIPE_PRIM_TRIANGLES) {
- return FALSE;
+ if (reduced_prim != MESA_PRIM_TRIANGLES) {
+ return false;
}
return (rast &&
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_context.h b/lib/mesa/src/gallium/auxiliary/draw/draw_context.h
index 44acf0116..e4a252c86 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_context.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_context.h
@@ -39,6 +39,7 @@
#include "pipe/p_state.h"
+#include "pipe/p_shader_tokens.h"
#include "nir.h"
struct pipe_context;
@@ -48,6 +49,7 @@ struct draw_vertex_shader;
struct draw_geometry_shader;
struct draw_tess_ctrl_shader;
struct draw_tess_eval_shader;
+struct draw_mesh_shader;
struct draw_fragment_shader;
struct tgsi_sampler;
struct tgsi_image;
@@ -69,6 +71,26 @@ struct draw_so_target {
};
+struct draw_vertex_info {
+ struct vertex_header *verts;
+ unsigned vertex_size;
+ unsigned stride;
+ unsigned count;
+};
+
+struct draw_prim_info {
+ bool linear;
+ unsigned start;
+
+ const uint16_t *elts;
+ unsigned count;
+
+ enum mesa_prim prim;
+ unsigned flags;
+ unsigned *primitive_lengths;
+ unsigned primitive_count;
+};
+
struct draw_context *draw_create(struct pipe_context *pipe);
#ifdef DRAW_LLVM_AVAILABLE
@@ -114,27 +136,27 @@ void draw_set_rasterize_stage(struct draw_context *draw,
void draw_wide_point_threshold(struct draw_context *draw, float threshold);
-void draw_wide_point_sprites(struct draw_context *draw, boolean draw_sprite);
+void draw_wide_point_sprites(struct draw_context *draw, bool draw_sprite);
void draw_wide_line_threshold(struct draw_context *draw, float threshold);
-void draw_enable_line_stipple(struct draw_context *draw, boolean enable);
+void draw_enable_line_stipple(struct draw_context *draw, bool enable);
-void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
+void draw_enable_point_sprites(struct draw_context *draw, bool enable);
void draw_set_zs_format(struct draw_context *draw, enum pipe_format format);
/* for TGSI constants are 4 * sizeof(float), but for NIR they need to be sizeof(float); */
void draw_set_constant_buffer_stride(struct draw_context *draw, unsigned num_bytes);
-boolean
+bool
draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
-boolean
+bool
draw_install_aapoint_stage(struct draw_context *draw, struct pipe_context *pipe,
nir_alu_type bool_type);
-boolean
+bool
draw_install_pstipple_stage(struct draw_context *draw, struct pipe_context *pipe);
@@ -146,24 +168,25 @@ draw_prepare_shader_outputs(struct draw_context *draw);
int
draw_find_shader_output(const struct draw_context *draw,
- uint semantic_name, uint semantic_index);
+ enum tgsi_semantic semantic_name,
+ unsigned semantic_index);
-boolean
+bool
draw_will_inject_frontface(const struct draw_context *draw);
-uint
+unsigned
draw_num_shader_outputs(const struct draw_context *draw);
-uint
+unsigned
draw_total_vs_outputs(const struct draw_context *draw);
-uint
+unsigned
draw_total_gs_outputs(const struct draw_context *draw);
-uint
+unsigned
draw_total_tcs_outputs(const struct draw_context *draw);
-uint
+unsigned
draw_total_tes_outputs(const struct draw_context *draw);
void
@@ -282,11 +305,22 @@ void draw_set_tess_state(struct draw_context *draw,
const float default_inner_level[2]);
/*
+ * Mesh shader functions
+ */
+struct draw_mesh_shader *
+draw_create_mesh_shader(struct draw_context *draw,
+ const struct pipe_shader_state *shader);
+void draw_bind_mesh_shader(struct draw_context *draw,
+ struct draw_mesh_shader *dvs);
+void draw_delete_mesh_shader(struct draw_context *draw,
+ struct draw_mesh_shader *dvs);
+
+/*
* Vertex data functions
*/
void draw_set_vertex_buffers(struct draw_context *draw,
- unsigned start_slot, unsigned count,
+ unsigned count,
unsigned unbind_num_trailing_slots,
const struct pipe_vertex_buffer *buffers);
@@ -334,6 +368,11 @@ void draw_vbo(struct draw_context *draw,
unsigned num_draws,
uint8_t patch_vertices);
+void
+draw_mesh(struct draw_context *draw,
+ struct draw_vertex_info *vert_info,
+ struct draw_prim_info *prim_info);
+
/*******************************************************************************
* Driver backend interface
@@ -345,17 +384,17 @@ draw_set_render(struct draw_context *draw,
void
draw_set_driver_clipping(struct draw_context *draw,
- boolean bypass_clip_xy,
- boolean bypass_clip_z,
- boolean guard_band_xy,
- boolean bypass_clip_points);
+ bool bypass_clip_xy,
+ bool bypass_clip_z,
+ bool guard_band_xy,
+ bool bypass_clip_points_lines);
/*******************************************************************************
* Draw statistics
*/
void
draw_collect_pipeline_statistics(struct draw_context *draw,
- boolean enable);
+ bool enable);
void
draw_collect_primitives_generated(struct draw_context *draw,
@@ -364,10 +403,10 @@ draw_collect_primitives_generated(struct draw_context *draw,
/*******************************************************************************
* Draw pipeline
*/
-boolean
+bool
draw_need_pipeline(const struct draw_context *draw,
const struct pipe_rasterizer_state *rasterizer,
- enum pipe_prim_type prim);
+ enum mesa_prim prim);
int
draw_get_shader_param(enum pipe_shader_type shader, enum pipe_shader_cap param);
@@ -376,7 +415,7 @@ int
draw_get_shader_param_no_llvm(enum pipe_shader_type shader,
enum pipe_shader_cap param);
-boolean
+bool
draw_get_option_use_llvm(void);
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_gs_tmp.h b/lib/mesa/src/gallium/auxiliary/draw/draw_gs_tmp.h
index 50a784bf9..3923a8f4f 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_gs_tmp.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_gs_tmp.h
@@ -9,13 +9,13 @@
const unsigned prim = input_prims->prim; \
const unsigned prim_flags = input_prims->flags; \
const unsigned count = input_prims->count; \
- const boolean quads_flatshade_last = FALSE; \
- const boolean last_vertex_last = !gs->draw->rasterizer->flatshade_first; \
+ const bool quads_flatshade_last = false; \
+ const bool last_vertex_last = !gs->draw->rasterizer->flatshade_first; \
do { \
switch (prim) { \
- case PIPE_PRIM_QUADS: \
- case PIPE_PRIM_QUAD_STRIP: \
- case PIPE_PRIM_POLYGON: \
+ case MESA_PRIM_QUADS: \
+ case MESA_PRIM_QUAD_STRIP: \
+ case MESA_PRIM_POLYGON: \
assert(!"unexpected primitive type in GS"); \
return; \
default: \
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_llvm.c b/lib/mesa/src/gallium/auxiliary/draw/draw_llvm.c
index 8b3a15227..3516fce63 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_llvm.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_llvm.c
@@ -52,6 +52,7 @@
#include "gallivm/lp_bld_pack.h"
#include "gallivm/lp_bld_format.h"
#include "gallivm/lp_bld_misc.h"
+#include "gallivm/lp_bld_jit_sample.h"
#include "tgsi/tgsi_exec.h"
#include "tgsi/tgsi_dump.h"
@@ -143,220 +144,27 @@ create_jit_dvbuffer_type(struct gallivm_state *gallivm,
return dvbuffer_type;
}
-
-/**
- * Create LLVM type for struct draw_jit_texture
- */
-static LLVMTypeRef
-create_jit_texture_type(struct gallivm_state *gallivm, const char *struct_name)
-{
- LLVMTargetDataRef target = gallivm->target;
- LLVMTypeRef texture_type;
- LLVMTypeRef elem_types[DRAW_JIT_TEXTURE_NUM_FIELDS];
- LLVMTypeRef int32_type = LLVMInt32TypeInContext(gallivm->context);
-
- elem_types[DRAW_JIT_TEXTURE_WIDTH] =
- elem_types[DRAW_JIT_TEXTURE_HEIGHT] =
- elem_types[DRAW_JIT_TEXTURE_DEPTH] =
- elem_types[DRAW_JIT_TEXTURE_NUM_SAMPLES] =
- elem_types[DRAW_JIT_TEXTURE_SAMPLE_STRIDE] =
- elem_types[DRAW_JIT_TEXTURE_FIRST_LEVEL] =
- elem_types[DRAW_JIT_TEXTURE_LAST_LEVEL] = int32_type;
- elem_types[DRAW_JIT_TEXTURE_BASE] =
- LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0);
- elem_types[DRAW_JIT_TEXTURE_ROW_STRIDE] =
- elem_types[DRAW_JIT_TEXTURE_IMG_STRIDE] =
- elem_types[DRAW_JIT_TEXTURE_MIP_OFFSETS] =
- LLVMArrayType(int32_type, PIPE_MAX_TEXTURE_LEVELS);
-
- texture_type = LLVMStructTypeInContext(gallivm->context, elem_types,
- ARRAY_SIZE(elem_types), 0);
-
- (void) target; /* silence unused var warning for non-debug build */
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, width,
- target, texture_type,
- DRAW_JIT_TEXTURE_WIDTH);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, height,
- target, texture_type,
- DRAW_JIT_TEXTURE_HEIGHT);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, depth,
- target, texture_type,
- DRAW_JIT_TEXTURE_DEPTH);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, base,
- target, texture_type,
- DRAW_JIT_TEXTURE_BASE);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, row_stride,
- target, texture_type,
- DRAW_JIT_TEXTURE_ROW_STRIDE);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, img_stride,
- target, texture_type,
- DRAW_JIT_TEXTURE_IMG_STRIDE);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, first_level,
- target, texture_type,
- DRAW_JIT_TEXTURE_FIRST_LEVEL);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, last_level,
- target, texture_type,
- DRAW_JIT_TEXTURE_LAST_LEVEL);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, mip_offsets,
- target, texture_type,
- DRAW_JIT_TEXTURE_MIP_OFFSETS);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, num_samples,
- target, texture_type,
- DRAW_JIT_TEXTURE_NUM_SAMPLES);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_texture, sample_stride,
- target, texture_type,
- DRAW_JIT_TEXTURE_SAMPLE_STRIDE);
-
- LP_CHECK_STRUCT_SIZE(struct draw_jit_texture, target, texture_type);
-
- return texture_type;
-}
-
-
-/**
- * Create LLVM type for struct draw_jit_sampler
- */
-static LLVMTypeRef
-create_jit_sampler_type(struct gallivm_state *gallivm, const char *struct_name)
-{
- LLVMTargetDataRef target = gallivm->target;
- LLVMTypeRef sampler_type;
- LLVMTypeRef elem_types[DRAW_JIT_SAMPLER_NUM_FIELDS];
-
- elem_types[DRAW_JIT_SAMPLER_MIN_LOD] =
- elem_types[DRAW_JIT_SAMPLER_MAX_LOD] =
- elem_types[DRAW_JIT_SAMPLER_LOD_BIAS] =
- elem_types[DRAW_JIT_SAMPLER_MAX_ANISO] = LLVMFloatTypeInContext(gallivm->context);
- elem_types[DRAW_JIT_SAMPLER_BORDER_COLOR] =
- LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
-
- sampler_type = LLVMStructTypeInContext(gallivm->context, elem_types,
- ARRAY_SIZE(elem_types), 0);
-
- (void) target; /* silence unused var warning for non-debug build */
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, min_lod,
- target, sampler_type,
- DRAW_JIT_SAMPLER_MIN_LOD);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, max_lod,
- target, sampler_type,
- DRAW_JIT_SAMPLER_MAX_LOD);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, lod_bias,
- target, sampler_type,
- DRAW_JIT_SAMPLER_LOD_BIAS);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, border_color,
- target, sampler_type,
- DRAW_JIT_SAMPLER_BORDER_COLOR);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_sampler, max_aniso,
- target, sampler_type,
- DRAW_JIT_SAMPLER_MAX_ANISO);
-
- LP_CHECK_STRUCT_SIZE(struct draw_jit_sampler, target, sampler_type);
-
- return sampler_type;
-}
-
-
-/**
- * Create LLVM type for struct draw_jit_texture
- */
-static LLVMTypeRef
-create_jit_image_type(struct gallivm_state *gallivm, const char *struct_name)
-{
- LLVMTargetDataRef target = gallivm->target;
- LLVMTypeRef image_type;
- LLVMTypeRef elem_types[DRAW_JIT_IMAGE_NUM_FIELDS];
- LLVMTypeRef int32_type = LLVMInt32TypeInContext(gallivm->context);
-
- elem_types[DRAW_JIT_IMAGE_WIDTH] =
- elem_types[DRAW_JIT_IMAGE_HEIGHT] =
- elem_types[DRAW_JIT_IMAGE_DEPTH] =
- elem_types[DRAW_JIT_IMAGE_ROW_STRIDE] =
- elem_types[DRAW_JIT_IMAGE_IMG_STRIDE] =
- elem_types[DRAW_JIT_IMAGE_NUM_SAMPLES] =
- elem_types[DRAW_JIT_IMAGE_SAMPLE_STRIDE] = int32_type;
- elem_types[DRAW_JIT_IMAGE_BASE] =
- LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0);
-
- image_type = LLVMStructTypeInContext(gallivm->context, elem_types,
- ARRAY_SIZE(elem_types), 0);
-
- (void) target; /* silence unused var warning for non-debug build */
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, width,
- target, image_type,
- DRAW_JIT_IMAGE_WIDTH);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, height,
- target, image_type,
- DRAW_JIT_IMAGE_HEIGHT);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, depth,
- target, image_type,
- DRAW_JIT_IMAGE_DEPTH);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, base,
- target, image_type,
- DRAW_JIT_IMAGE_BASE);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, row_stride,
- target, image_type,
- DRAW_JIT_IMAGE_ROW_STRIDE);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, img_stride,
- target, image_type,
- DRAW_JIT_IMAGE_IMG_STRIDE);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, num_samples,
- target, image_type,
- DRAW_JIT_IMAGE_NUM_SAMPLES);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_image, sample_stride,
- target, image_type,
- DRAW_JIT_IMAGE_SAMPLE_STRIDE);
-
- LP_CHECK_STRUCT_SIZE(struct draw_jit_image, target, image_type);
-
- return image_type;
-}
-
-
/**
* Create LLVM type for struct draw_jit_context
*/
static LLVMTypeRef
-create_jit_context_type(struct gallivm_state *gallivm, const char *struct_name)
+create_vs_jit_context_type(struct gallivm_state *gallivm, const char *struct_name)
{
- LLVMTypeRef buffer_type = lp_build_create_jit_buffer_type(gallivm);
- LLVMTypeRef texture_type = create_jit_texture_type(gallivm, "texture");
- LLVMTypeRef sampler_type = create_jit_sampler_type(gallivm, "sampler");
- LLVMTypeRef image_type = create_jit_image_type(gallivm, "image");
-
LLVMTargetDataRef target = gallivm->target;
LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
- LLVMTypeRef elem_types[DRAW_JIT_CTX_NUM_FIELDS];
-
- elem_types[DRAW_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, LP_MAX_TGSI_CONST_BUFFERS);
- elem_types[DRAW_JIT_CTX_PLANES] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES), 0);
- elem_types[DRAW_JIT_CTX_VIEWPORT] = LLVMPointerType(float_type, 0);
- elem_types[DRAW_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type, PIPE_MAX_SHADER_SAMPLER_VIEWS);
- elem_types[DRAW_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type, PIPE_MAX_SAMPLERS);
- elem_types[DRAW_JIT_CTX_IMAGES] = LLVMArrayType(image_type, PIPE_MAX_SHADER_IMAGES);
- elem_types[DRAW_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, LP_MAX_TGSI_SHADER_BUFFERS);
- elem_types[DRAW_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0);
+ LLVMTypeRef elem_types[DRAW_VS_JIT_CTX_NUM_FIELDS];
+
+ elem_types[DRAW_VS_JIT_CTX_PLANES] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES), 0);
+ elem_types[DRAW_VS_JIT_CTX_VIEWPORT] = LLVMPointerType(float_type, 0);
+
LLVMTypeRef context_type = LLVMStructTypeInContext(gallivm->context, elem_types, ARRAY_SIZE(elem_types), 0);
(void) target; /* silence unused var warning for non-debug build */
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, constants,
- target, context_type, DRAW_JIT_CTX_CONSTANTS);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, planes,
- target, context_type, DRAW_JIT_CTX_PLANES);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, viewports,
- target, context_type, DRAW_JIT_CTX_VIEWPORT);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, textures,
- target, context_type,
- DRAW_JIT_CTX_TEXTURES);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, samplers,
- target, context_type,
- DRAW_JIT_CTX_SAMPLERS);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, images,
- target, context_type, DRAW_JIT_CTX_IMAGES);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, ssbos,
- target, context_type, DRAW_JIT_CTX_SSBOS);
- LP_CHECK_MEMBER_OFFSET(struct draw_jit_context, aniso_filter_table,
- target, context_type, DRAW_JIT_CTX_ANISO_FILTER_TABLE);
- LP_CHECK_STRUCT_SIZE(struct draw_jit_context,
+ LP_CHECK_MEMBER_OFFSET(struct draw_vs_jit_context, planes,
+ target, context_type, DRAW_VS_JIT_CTX_PLANES);
+ LP_CHECK_MEMBER_OFFSET(struct draw_vs_jit_context, viewports,
+ target, context_type, DRAW_VS_JIT_CTX_VIEWPORT);
+ LP_CHECK_STRUCT_SIZE(struct draw_vs_jit_context,
target, context_type);
return context_type;
@@ -369,9 +177,6 @@ create_jit_context_type(struct gallivm_state *gallivm, const char *struct_name)
static LLVMTypeRef
create_gs_jit_context_type(struct gallivm_state *gallivm,
unsigned vector_length,
- LLVMTypeRef buffer_type,
- LLVMTypeRef texture_type, LLVMTypeRef sampler_type,
- LLVMTypeRef image_type,
const char *struct_name)
{
LLVMTargetDataRef target = gallivm->target;
@@ -380,44 +185,25 @@ create_gs_jit_context_type(struct gallivm_state *gallivm,
LLVMTypeRef elem_types[DRAW_GS_JIT_CTX_NUM_FIELDS];
LLVMTypeRef context_type;
- elem_types[DRAW_GS_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
- LP_MAX_TGSI_CONST_BUFFERS);
elem_types[DRAW_GS_JIT_CTX_PLANES] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4),
DRAW_TOTAL_CLIP_PLANES), 0);
elem_types[DRAW_GS_JIT_CTX_VIEWPORT] = LLVMPointerType(float_type, 0); /* viewports */
- elem_types[DRAW_GS_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
- PIPE_MAX_SHADER_SAMPLER_VIEWS); /* textures */
- elem_types[DRAW_GS_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
- PIPE_MAX_SAMPLERS); /* samplers */
- elem_types[DRAW_GS_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
- PIPE_MAX_SHADER_IMAGES); /* images */
+
elem_types[DRAW_GS_JIT_CTX_PRIM_LENGTHS] = LLVMPointerType(LLVMPointerType(int_type, 0), 0);
elem_types[DRAW_GS_JIT_CTX_EMITTED_VERTICES] = LLVMPointerType(LLVMVectorType(int_type,
vector_length), 0);
elem_types[DRAW_GS_JIT_CTX_EMITTED_PRIMS] = LLVMPointerType(LLVMVectorType(int_type,
vector_length), 0);
- elem_types[DRAW_GS_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
- LP_MAX_TGSI_SHADER_BUFFERS);
- elem_types[DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0); /* aniso table */
-
context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
ARRAY_SIZE(elem_types), 0);
(void) target; /* silence unused var warning for non-debug build */
- LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, constants,
- target, context_type, DRAW_GS_JIT_CTX_CONSTANTS);
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, planes,
target, context_type, DRAW_GS_JIT_CTX_PLANES);
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, viewports,
target, context_type, DRAW_GS_JIT_CTX_VIEWPORT);
- LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, textures,
- target, context_type,
- DRAW_GS_JIT_CTX_TEXTURES);
- LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, samplers,
- target, context_type,
- DRAW_GS_JIT_CTX_SAMPLERS);
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, prim_lengths,
target, context_type,
DRAW_GS_JIT_CTX_PRIM_LENGTHS);
@@ -427,15 +213,8 @@ create_gs_jit_context_type(struct gallivm_state *gallivm,
LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, emitted_prims,
target, context_type,
DRAW_GS_JIT_CTX_EMITTED_PRIMS);
- LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, ssbos,
- target, context_type, DRAW_GS_JIT_CTX_SSBOS);
- LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, images,
- target, context_type, DRAW_GS_JIT_CTX_IMAGES);
- LP_CHECK_MEMBER_OFFSET(struct draw_gs_jit_context, aniso_filter_table,
- target, context_type, DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE);
LP_CHECK_STRUCT_SIZE(struct draw_gs_jit_context,
target, context_type);
-
return context_type;
}
@@ -468,26 +247,23 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm,
const char *struct_name)
{
LLVMTargetDataRef target = gallivm->target;
- LLVMTypeRef elem_types[4];
+ LLVMTypeRef elem_types[3];
LLVMTypeRef vb_type;
- elem_types[0] = LLVMInt16TypeInContext(gallivm->context);
- elem_types[1] = LLVMInt8TypeInContext(gallivm->context);
- elem_types[2] = LLVMInt32TypeInContext(gallivm->context);
- elem_types[3] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0);
+ elem_types[0] = LLVMInt8TypeInContext(gallivm->context);
+ elem_types[1] = LLVMInt32TypeInContext(gallivm->context);
+ elem_types[2] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0);
vb_type = LLVMStructTypeInContext(gallivm->context, elem_types,
ARRAY_SIZE(elem_types), 0);
(void) target; /* silence unused var warning for non-debug build */
- LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride,
- target, vb_type, 0);
LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, is_user_buffer,
- target, vb_type, 1);
+ target, vb_type, 0);
LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, buffer_offset,
- target, vb_type, 2);
+ target, vb_type, 1);
LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, buffer.resource,
- target, vb_type, 3);
+ target, vb_type, 2);
LP_CHECK_STRUCT_SIZE(struct pipe_vertex_buffer, target, vb_type);
@@ -495,113 +271,6 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm,
}
-/**
- * Create LLVM type for struct vertex_header;
- */
-static LLVMTypeRef
-create_jit_vertex_header(struct gallivm_state *gallivm, int data_elems)
-{
- LLVMTargetDataRef target = gallivm->target;
- LLVMTypeRef elem_types[3];
- LLVMTypeRef vertex_header;
- char struct_name[24];
-
- snprintf(struct_name, 23, "vertex_header%d", data_elems);
-
- elem_types[DRAW_JIT_VERTEX_VERTEX_ID] = LLVMIntTypeInContext(gallivm->context, 32);
- elem_types[DRAW_JIT_VERTEX_CLIP_POS] = LLVMArrayType(LLVMFloatTypeInContext(gallivm->context), 4);
- elem_types[DRAW_JIT_VERTEX_DATA] = LLVMArrayType(elem_types[1], data_elems);
-
- vertex_header = LLVMStructTypeInContext(gallivm->context, elem_types,
- ARRAY_SIZE(elem_types), 0);
-
- /* these are bit-fields and we can't take address of them
- LP_CHECK_MEMBER_OFFSET(struct vertex_header, clipmask,
- target, vertex_header,
- DRAW_JIT_VERTEX_CLIPMASK);
- LP_CHECK_MEMBER_OFFSET(struct vertex_header, edgeflag,
- target, vertex_header,
- DRAW_JIT_VERTEX_EDGEFLAG);
- LP_CHECK_MEMBER_OFFSET(struct vertex_header, pad,
- target, vertex_header,
- DRAW_JIT_VERTEX_PAD);
- LP_CHECK_MEMBER_OFFSET(struct vertex_header, vertex_id,
- target, vertex_header,
- DRAW_JIT_VERTEX_VERTEX_ID);
- */
- (void) target; /* silence unused var warning for non-debug build */
- LP_CHECK_MEMBER_OFFSET(struct vertex_header, clip_pos,
- target, vertex_header,
- DRAW_JIT_VERTEX_CLIP_POS);
- LP_CHECK_MEMBER_OFFSET(struct vertex_header, data,
- target, vertex_header,
- DRAW_JIT_VERTEX_DATA);
-
- assert(LLVMABISizeOfType(target, vertex_header) ==
- offsetof(struct vertex_header, data[data_elems]));
-
- return vertex_header;
-}
-
-
-/**
- * Create LLVM type for struct draw_tcs_jit_context
- */
-static LLVMTypeRef
-create_tcs_jit_context_type(struct gallivm_state *gallivm,
- unsigned vector_length,
- LLVMTypeRef buffer_type,
- LLVMTypeRef texture_type, LLVMTypeRef sampler_type,
- LLVMTypeRef image_type,
- const char *struct_name)
-{
- LLVMTargetDataRef target = gallivm->target;
- LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
- LLVMTypeRef elem_types[DRAW_TCS_JIT_CTX_NUM_FIELDS];
- LLVMTypeRef context_type;
-
-
- elem_types[DRAW_TCS_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
- LP_MAX_TGSI_CONST_BUFFERS);
- elem_types[DRAW_TCS_JIT_CTX_DUMMY1] = LLVMInt32TypeInContext(gallivm->context);
- elem_types[DRAW_TCS_JIT_CTX_DUMMY2] = LLVMInt32TypeInContext(gallivm->context);
-
- elem_types[DRAW_TCS_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
- PIPE_MAX_SHADER_SAMPLER_VIEWS); /* textures */
- elem_types[DRAW_TCS_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
- PIPE_MAX_SAMPLERS); /* samplers */
- elem_types[DRAW_TCS_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
- PIPE_MAX_SHADER_IMAGES); /* images */
-
- elem_types[DRAW_TCS_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
- LP_MAX_TGSI_SHADER_BUFFERS);
- elem_types[DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0); /* aniso table */
-
- context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
- ARRAY_SIZE(elem_types), 0);
-
- (void) target; /* silence unused var warning for non-debug build */
- LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, constants,
- target, context_type, DRAW_TCS_JIT_CTX_CONSTANTS);
- LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, textures,
- target, context_type,
- DRAW_TCS_JIT_CTX_TEXTURES);
- LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, samplers,
- target, context_type,
- DRAW_TCS_JIT_CTX_SAMPLERS);
- LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, ssbos,
- target, context_type, DRAW_TCS_JIT_CTX_SSBOS);
- LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, images,
- target, context_type, DRAW_TCS_JIT_CTX_IMAGES);
- LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, aniso_filter_table,
- target, context_type, DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE);
- LP_CHECK_STRUCT_SIZE(struct draw_tcs_jit_context,
- target, context_type);
-
- return context_type;
-}
-
-
static LLVMTypeRef
create_tcs_jit_input_type_deref(struct gallivm_state *gallivm)
{
@@ -654,73 +323,19 @@ create_tes_jit_input_deref_type(struct gallivm_state *gallivm)
/**
- * Create LLVM type for struct draw_tes_jit_context
- */
-static LLVMTypeRef
-create_tes_jit_context_type(struct gallivm_state *gallivm,
- unsigned vector_length,
- LLVMTypeRef buffer_type,
- LLVMTypeRef texture_type, LLVMTypeRef sampler_type,
- LLVMTypeRef image_type,
- const char *struct_name)
-{
- LLVMTargetDataRef target = gallivm->target;
- LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
- LLVMTypeRef elem_types[DRAW_TES_JIT_CTX_NUM_FIELDS];
- LLVMTypeRef context_type;
-
- elem_types[DRAW_TES_JIT_CTX_CONSTANTS] = LLVMArrayType(buffer_type, /* constants */
- LP_MAX_TGSI_CONST_BUFFERS);
- elem_types[DRAW_TES_JIT_CTX_DUMMY1] = LLVMInt32TypeInContext(gallivm->context);
- elem_types[DRAW_TES_JIT_CTX_DUMMY2] = LLVMInt32TypeInContext(gallivm->context);
-
- elem_types[DRAW_TES_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
- PIPE_MAX_SHADER_SAMPLER_VIEWS); /* textures */
- elem_types[DRAW_TES_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
- PIPE_MAX_SAMPLERS); /* samplers */
- elem_types[DRAW_TES_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
- PIPE_MAX_SHADER_IMAGES); /* images */
-
- elem_types[DRAW_TES_JIT_CTX_SSBOS] = LLVMArrayType(buffer_type, /* ssbos */
- LP_MAX_TGSI_SHADER_BUFFERS);
- elem_types[DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE] = LLVMPointerType(float_type, 0); /* aniso table */
-
- context_type = LLVMStructTypeInContext(gallivm->context, elem_types,
- ARRAY_SIZE(elem_types), 0);
-
- (void) target; /* silence unused var warning for non-debug build */
- LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, constants,
- target, context_type, DRAW_TES_JIT_CTX_CONSTANTS);
- LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, textures,
- target, context_type,
- DRAW_TES_JIT_CTX_TEXTURES);
- LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, samplers,
- target, context_type,
- DRAW_TES_JIT_CTX_SAMPLERS);
- LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, ssbos,
- target, context_type, DRAW_TES_JIT_CTX_SSBOS);
- LP_CHECK_MEMBER_OFFSET(struct draw_tes_jit_context, images,
- target, context_type, DRAW_TES_JIT_CTX_IMAGES);
- LP_CHECK_MEMBER_OFFSET(struct draw_tcs_jit_context, aniso_filter_table,
- target, context_type, DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE);
- LP_CHECK_STRUCT_SIZE(struct draw_tes_jit_context,
- target, context_type);
-
- return context_type;
-}
-
-
-/**
* Create LLVM types for various structures.
*/
static void
-create_jit_types(struct draw_llvm_variant *variant)
+create_vs_jit_types(struct draw_llvm_variant *variant)
{
struct gallivm_state *gallivm = variant->gallivm;
- variant->context_type = create_jit_context_type(gallivm, "draw_jit_context");
+ variant->context_type = create_vs_jit_context_type(gallivm, "draw_vs_jit_context");
variant->context_ptr_type = LLVMPointerType(variant->context_type, 0);
+ variant->resources_type = lp_build_jit_resources_type(gallivm);
+ variant->resources_ptr_type = LLVMPointerType(variant->resources_type, 0);
+
variant->buffer_type = create_jit_dvbuffer_type(gallivm, "draw_vertex_buffer");
variant->buffer_ptr_type = LLVMPointerType(variant->buffer_type, 0);
@@ -733,7 +348,7 @@ static LLVMTypeRef
get_context_ptr_type(struct draw_llvm_variant *variant)
{
if (!variant->context_ptr_type)
- create_jit_types(variant);
+ create_vs_jit_types(variant);
return variant->context_ptr_type;
}
@@ -742,7 +357,7 @@ static LLVMTypeRef
get_buffer_ptr_type(struct draw_llvm_variant *variant)
{
if (!variant->buffer_ptr_type)
- create_jit_types(variant);
+ create_vs_jit_types(variant);
return variant->buffer_ptr_type;
}
@@ -751,7 +366,7 @@ static LLVMTypeRef
get_vb_ptr_type(struct draw_llvm_variant *variant)
{
if (!variant->vb_ptr_type)
- create_jit_types(variant);
+ create_vs_jit_types(variant);
return variant->vb_ptr_type;
}
@@ -897,7 +512,7 @@ draw_llvm_create_variant(struct draw_llvm *llvm,
}
variant->gallivm = gallivm_create(module_name, llvm->context, &cached);
- create_jit_types(variant);
+ create_vs_jit_types(variant);
if (gallivm_debug & (GALLIVM_DEBUG_TGSI | GALLIVM_DEBUG_IR)) {
if (llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_TGSI)
@@ -907,7 +522,7 @@ draw_llvm_create_variant(struct draw_llvm *llvm,
draw_llvm_dump_variant_key(&variant->key);
}
- variant->vertex_header_type = create_jit_vertex_header(variant->gallivm, num_inputs);
+ variant->vertex_header_type = lp_build_create_jit_vertex_header_type(variant->gallivm, num_inputs);
variant->vertex_header_ptr_type = LLVMPointerType(variant->vertex_header_type, 0);
draw_llvm_generate(llvm, variant);
@@ -969,17 +584,18 @@ generate_vs(struct draw_llvm_variant *variant,
const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS],
const struct lp_bld_tgsi_system_values *system_values,
LLVMValueRef context_ptr,
+ LLVMValueRef resources_ptr,
const struct lp_build_sampler_soa *draw_sampler,
const struct lp_build_image_soa *draw_image,
- boolean clamp_vertex_color,
+ bool clamp_vertex_color,
struct lp_build_mask_context *bld_mask)
{
struct draw_llvm *llvm = variant->llvm;
const struct tgsi_token *tokens = llvm->draw->vs.vertex_shader->state.tokens;
LLVMValueRef consts_ptr =
- draw_jit_context_constants(variant, context_ptr);
+ lp_jit_resources_constants(variant->gallivm, variant->resources_type, resources_ptr);
LLVMValueRef ssbos_ptr =
- draw_jit_context_ssbos(variant, context_ptr);
+ lp_jit_resources_ssbos(variant->gallivm, variant->resources_type, resources_ptr);
struct lp_build_tgsi_params params;
memset(&params, 0, sizeof(params));
@@ -991,11 +607,15 @@ generate_vs(struct draw_llvm_variant *variant,
params.inputs = inputs;
params.context_type = variant->context_type;
params.context_ptr = context_ptr;
+ params.resources_type = variant->resources_type;
+ params.resources_ptr = resources_ptr;
params.sampler = draw_sampler;
params.info = &llvm->draw->vs.vertex_shader->info;
params.ssbo_ptr = ssbos_ptr;
params.image = draw_image;
- params.aniso_filter_table = draw_jit_context_aniso_filter_table(variant, context_ptr);
+ params.aniso_filter_table = lp_jit_resources_aniso_filter_table(variant->gallivm,
+ variant->resources_type,
+ resources_ptr);
if (llvm->draw->vs.vertex_shader->state.ir.nir &&
llvm->draw->vs.vertex_shader->state.type == PIPE_SHADER_IR_NIR) {
@@ -1058,7 +678,7 @@ fetch_instanced(struct gallivm_state *gallivm,
aos = lp_build_fetch_rgba_aos(gallivm,
format_desc,
lp_float32_vec4_type(),
- FALSE,
+ false,
map_ptr,
stride, zero, zero,
NULL);
@@ -1129,7 +749,7 @@ fetch_vector(struct gallivm_state *gallivm,
}
lp_build_fetch_rgba_soa(gallivm, format_desc,
- fetch_type, FALSE, map_ptr, offset,
+ fetch_type, false, map_ptr, offset,
blduivec.zero, blduivec.zero,
NULL, inputs);
@@ -1150,6 +770,7 @@ fetch_vector(struct gallivm_state *gallivm,
static void
store_aos(struct gallivm_state *gallivm,
+ bool is_per_prim,
LLVMTypeRef io_type,
LLVMValueRef io_ptr,
LLVMValueRef index,
@@ -1157,19 +778,30 @@ store_aos(struct gallivm_state *gallivm,
{
LLVMTypeRef data_ptr_type = LLVMPointerType(lp_build_vec_type(gallivm, lp_float32_vec4_type()), 0);
LLVMBuilderRef builder = gallivm->builder;
- LLVMValueRef data_ptr = draw_jit_header_data(gallivm, io_type, io_ptr);
- LLVMTypeRef data_type = LLVMStructGetTypeAtIndex(io_type, DRAW_JIT_VERTEX_DATA);
+ LLVMValueRef data_ptr;
+ LLVMTypeRef data_type;
LLVMValueRef indices[3];
indices[0] = lp_build_const_int32(gallivm, 0);
indices[1] = index;
indices[2] = lp_build_const_int32(gallivm, 0);
+ if (!is_per_prim) {
+ data_ptr = lp_jit_vertex_header_data(gallivm, io_type, io_ptr);
+ data_type = LLVMStructGetTypeAtIndex(io_type, LP_JIT_VERTEX_HEADER_DATA);
+ } else {
+ data_ptr = io_ptr;
+ data_type = io_type;
+ }
+
data_ptr = LLVMBuildGEP2(builder, data_type, data_ptr, indices, 3, "");
data_ptr = LLVMBuildPointerCast(builder, data_ptr, data_ptr_type, "");
#if DEBUG_STORE
- lp_build_printf(gallivm, " ---- %p storing attribute %d (io = %p)\n", data_ptr, index, io_ptr);
+ if (is_per_prim)
+ lp_build_printf(gallivm, " ---- %p storing prim attribute %d (io = %p)\n", data_ptr, index, io_ptr);
+ else
+ lp_build_printf(gallivm, " ---- %p storing attribute %d (io = %p)\n", data_ptr, index, io_ptr);
#endif
/* Unaligned store due to the vertex header */
@@ -1230,17 +862,16 @@ adjust_mask(struct gallivm_state *gallivm,
}
-static void
-store_aos_array(struct gallivm_state *gallivm,
- struct lp_type soa_type,
- LLVMTypeRef io_type,
- LLVMValueRef io_ptr,
- LLVMValueRef *indices,
- LLVMValueRef* aos,
- int attrib,
- int num_outputs,
- LLVMValueRef clipmask,
- boolean need_edgeflag)
+void
+draw_store_aos_array(struct gallivm_state *gallivm,
+ struct lp_type soa_type,
+ LLVMTypeRef io_type,
+ LLVMValueRef io_ptr,
+ LLVMValueRef *indices,
+ LLVMValueRef* aos,
+ int attrib,
+ LLVMValueRef clipmask,
+ bool need_edgeflag, bool is_per_prim)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef attr_index = lp_build_const_int32(gallivm, attrib);
@@ -1261,7 +892,7 @@ store_aos_array(struct gallivm_state *gallivm,
io_ptrs[i] = LLVMBuildGEP2(builder, io_type, io_ptr, &inds[i], 1, "");
}
- if (attrib == 0) {
+ if (attrib == 0 && !is_per_prim) {
/* store vertex header for each of the n vertices */
LLVMValueRef val, cliptmp;
int vertex_id_pad_edgeflag;
@@ -1276,13 +907,20 @@ store_aos_array(struct gallivm_state *gallivm,
} else {
vertex_id_pad_edgeflag = (0xffff << 16);
}
- val = lp_build_const_int_vec(gallivm, lp_int_type(soa_type),
- vertex_id_pad_edgeflag);
+ if (vector_length == 1)
+ val = lp_build_const_int32(gallivm, vertex_id_pad_edgeflag);
+ else
+ val = lp_build_const_int_vec(gallivm, lp_int_type(soa_type),
+ vertex_id_pad_edgeflag);
+
/* OR with the clipmask */
cliptmp = LLVMBuildOr(builder, val, clipmask, "");
for (unsigned i = 0; i < vector_length; i++) {
- LLVMValueRef id_ptr = draw_jit_header_id(gallivm, io_type, io_ptrs[i]);
- val = LLVMBuildExtractElement(builder, cliptmp, linear_inds[i], "");
+ LLVMValueRef id_ptr = lp_jit_vertex_header_id(gallivm, io_type, io_ptrs[i]);
+ if (vector_length > 1)
+ val = LLVMBuildExtractElement(builder, cliptmp, linear_inds[i], "");
+ else
+ val = cliptmp;
val = adjust_mask(gallivm, val);
#if DEBUG_STORE
lp_build_printf(gallivm, "io = %p, index %d, clipmask = %x\n",
@@ -1294,7 +932,7 @@ store_aos_array(struct gallivm_state *gallivm,
/* store for each of the n vertices */
for (int i = 0; i < vector_length; i++) {
- store_aos(gallivm, io_type, io_ptrs[i], attr_index, aos[i]);
+ store_aos(gallivm, is_per_prim, io_type, io_ptrs[i], attr_index, aos[i]);
}
}
@@ -1309,7 +947,7 @@ convert_to_aos(struct gallivm_state *gallivm,
int num_outputs,
struct lp_type soa_type,
int primid_slot,
- boolean need_edgeflag)
+ bool need_edgeflag)
{
LLVMBuilderRef builder = gallivm->builder;
@@ -1358,16 +996,15 @@ convert_to_aos(struct gallivm_state *gallivm,
}
}
- store_aos_array(gallivm,
- soa_type,
- io_type,
- io,
- indices,
- aos,
- attrib,
- num_outputs,
- clipmask,
- need_edgeflag);
+ draw_store_aos_array(gallivm,
+ soa_type,
+ io_type,
+ io,
+ indices,
+ aos,
+ attrib,
+ clipmask,
+ need_edgeflag, false);
}
#if DEBUG_STORE
lp_build_printf(gallivm, " # storing end\n");
@@ -1408,7 +1045,7 @@ store_clip(struct gallivm_state *gallivm,
soa[3] = LLVMBuildLoad2(builder, single_type, outputs[idx][3], ""); /*w0 w1 .. wn*/
for (int i = 0; i < vs_type.length; i++) {
- clip_ptrs[i] = draw_jit_header_clip_pos(gallivm, io_type, io_ptrs[i]);
+ clip_ptrs[i] = lp_jit_vertex_header_clip_pos(gallivm, io_type, io_ptrs[i]);
}
lp_build_transpose_aos(gallivm, vs_type, soa, soa);
@@ -1446,7 +1083,7 @@ generate_viewport(struct draw_llvm_variant *variant,
LLVMTypeRef vs_type_llvm = lp_build_vec_type(gallivm, vs_type);
LLVMValueRef out3 = LLVMBuildLoad2(builder, vs_type_llvm, outputs[pos][3], ""); /*w0 w1 .. wn*/
LLVMValueRef const1 = lp_build_const_vec(gallivm, f32_type, 1.0); /*1.0 1.0 1.0 1.0*/
- LLVMValueRef vp_ptr = draw_jit_context_viewports(variant, context_ptr);
+ LLVMValueRef vp_ptr = draw_vs_jit_context_viewports(variant, context_ptr);
/* We treat pipe_viewport_state as a float array */
const int scale_index_offset = offsetof(struct pipe_viewport_state, scale) / sizeof(float);
@@ -1501,7 +1138,7 @@ generate_clipmask(struct draw_llvm *llvm,
struct draw_llvm_variant_key *key,
LLVMTypeRef context_type,
LLVMValueRef context_ptr,
- boolean *have_clipdist)
+ bool *have_clipdist)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMValueRef mask; /* stores the <nxi32> clipmasks */
@@ -1515,8 +1152,8 @@ generate_clipmask(struct draw_llvm *llvm,
const unsigned pos = llvm->draw->vs.position_output;
const unsigned cv = llvm->draw->vs.clipvertex_output;
int num_written_clipdistance = llvm->draw->vs.vertex_shader->info.num_written_clipdistance;
- boolean have_cd = false;
- boolean clip_user = key->clip_user;
+ bool have_cd = false;
+ bool clip_user = key->clip_user;
unsigned ucp_enable = key->ucp_enable;
unsigned cd[2];
@@ -1618,7 +1255,7 @@ generate_clipmask(struct draw_llvm *llvm,
}
if (clip_user) {
- LLVMValueRef planes_ptr = draw_jit_context_planes(gallivm, context_type, context_ptr);
+ LLVMValueRef planes_ptr = draw_vs_jit_context_planes(gallivm, context_type, context_ptr);
LLVMTypeRef float_type = LLVMFloatTypeInContext(gallivm->context);
LLVMTypeRef planes_type = LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES);
LLVMValueRef indices[3];
@@ -1635,7 +1272,7 @@ generate_clipmask(struct draw_llvm *llvm,
int i;
i = plane_idx - 6;
- *have_clipdist = TRUE;
+ *have_clipdist = true;
if (i < 4) {
clipdist = LLVMBuildLoad2(builder, vec_type, outputs[cd[0]][i], "");
} else {
@@ -1701,7 +1338,7 @@ clipmask_booli8(struct gallivm_state *gallivm,
const struct lp_type vs_type,
LLVMTypeRef clipmask_bool_type,
LLVMValueRef clipmask_bool_ptr,
- boolean edgeflag_in_clipmask)
+ bool edgeflag_in_clipmask)
{
LLVMBuilderRef builder = gallivm->builder;
LLVMTypeRef int8_type = LLVMInt8TypeInContext(gallivm->context);
@@ -1738,9 +1375,9 @@ clipmask_booli8(struct gallivm_state *gallivm,
static LLVMValueRef
draw_gs_llvm_fetch_input(const struct lp_build_gs_iface *gs_iface,
struct lp_build_context * bld,
- boolean is_vindex_indirect,
+ bool is_vindex_indirect,
LLVMValueRef vertex_index,
- boolean is_aindex_indirect,
+ bool is_aindex_indirect,
LLVMValueRef attrib_index,
LLVMValueRef swizzle_index)
{
@@ -1842,7 +1479,7 @@ draw_gs_llvm_emit_vertex(const struct lp_build_gs_iface *gs_base,
outputs, clipmask,
gs_info->num_outputs, gs_type,
-1,
- FALSE);
+ false);
lp_build_endif(&if_ctx);
}
@@ -1916,10 +1553,11 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
struct gallivm_state *gallivm = variant->gallivm;
LLVMContextRef context = gallivm->context;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
- LLVMTypeRef arg_types[13];
+ LLVMTypeRef arg_types[14];
unsigned num_arg_types = ARRAY_SIZE(arg_types);
LLVMTypeRef func_type;
LLVMValueRef context_ptr;
+ LLVMValueRef resources_ptr;
LLVMBasicBlockRef block;
LLVMBuilderRef builder;
char func_name[64];
@@ -1954,16 +1592,16 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
* (though this would be fixable here, but couldn't just broadcast
* the values).
*/
- const boolean bypass_viewport = key->has_gs_or_tes || key->bypass_viewport ||
- vs_info->writes_viewport_index;
- const boolean enable_cliptest = !key->has_gs_or_tes && (key->clip_xy ||
+ const bool bypass_viewport = key->has_gs_or_tes || key->bypass_viewport ||
+ vs_info->writes_viewport_index;
+ const bool enable_cliptest = !key->has_gs_or_tes && (key->clip_xy ||
key->clip_z ||
key->clip_user ||
key->need_edgeflags);
LLVMValueRef variant_func;
const unsigned pos = draw->vs.position_output;
const unsigned cv = draw->vs.clipvertex_output;
- boolean have_clipdist = FALSE;
+ bool have_clipdist = false;
struct lp_bld_tgsi_system_values system_values;
memset(&system_values, 0, sizeof(system_values));
@@ -1972,6 +1610,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
i = 0;
arg_types[i++] = get_context_ptr_type(variant); /* context */
+ arg_types[i++] = variant->resources_ptr_type; /* context */
arg_types[i++] = get_vertex_header_ptr_type(variant); /* vertex_header */
arg_types[i++] = get_buffer_ptr_type(variant); /* vbuffers */
arg_types[i++] = int32_type; /* count */
@@ -1984,6 +1623,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
arg_types[i++] = LLVMPointerType(int32_type, 0); /* fetch_elts */
arg_types[i++] = int32_type; /* draw_id */
arg_types[i++] = int32_type; /* view_id */
+ assert(i == ARRAY_SIZE(arg_types));
func_type = LLVMFunctionType(LLVMInt8TypeInContext(context),
arg_types, num_arg_types, 0);
@@ -2000,26 +1640,28 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
return;
context_ptr = LLVMGetParam(variant_func, 0);
- io_ptr = LLVMGetParam(variant_func, 1);
- vbuffers_ptr = LLVMGetParam(variant_func, 2);
- count = LLVMGetParam(variant_func, 3);
- start = LLVMGetParam(variant_func, 4);
+ resources_ptr = LLVMGetParam(variant_func, 1);
+ io_ptr = LLVMGetParam(variant_func, 2);
+ vbuffers_ptr = LLVMGetParam(variant_func, 3);
+ count = LLVMGetParam(variant_func, 4);
+ start = LLVMGetParam(variant_func, 5);
/*
* XXX: stride is actually unused. The stride we use is strictly calculated
* from the number of outputs (including the draw_extra outputs).
* Should probably fix some day (we need a new vs just because of extra
* outputs which the generated vs won't touch).
*/
- stride = LLVMGetParam(variant_func, 5);
- vb_ptr = LLVMGetParam(variant_func, 6);
- system_values.instance_id = LLVMGetParam(variant_func, 7);
- vertex_id_offset = LLVMGetParam(variant_func, 8);
- system_values.base_instance = LLVMGetParam(variant_func, 9);
- fetch_elts = LLVMGetParam(variant_func, 10);
- system_values.draw_id = LLVMGetParam(variant_func, 11);
- system_values.view_index = LLVMGetParam(variant_func, 12);
+ stride = LLVMGetParam(variant_func, 6);
+ vb_ptr = LLVMGetParam(variant_func, 7);
+ system_values.instance_id = LLVMGetParam(variant_func, 8);
+ vertex_id_offset = LLVMGetParam(variant_func, 9);
+ system_values.base_instance = LLVMGetParam(variant_func, 10);
+ fetch_elts = LLVMGetParam(variant_func, 11);
+ system_values.draw_id = LLVMGetParam(variant_func, 12);
+ system_values.view_index = LLVMGetParam(variant_func, 13);
lp_build_name(context_ptr, "context");
+ lp_build_name(resources_ptr, "resources");
lp_build_name(io_ptr, "io");
lp_build_name(vbuffers_ptr, "vbuffers");
lp_build_name(count, "count");
@@ -2041,9 +1683,9 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
LLVMPositionBuilderAtEnd(builder, block);
memset(&vs_type, 0, sizeof vs_type);
- vs_type.floating = TRUE; /* floating point values */
- vs_type.sign = TRUE; /* values are signed */
- vs_type.norm = FALSE; /* values are not limited to [0,1] or [-1,1] */
+ vs_type.floating = true; /* floating point values */
+ vs_type.sign = true; /* values are signed */
+ vs_type.norm = false; /* values are not limited to [0,1] or [-1,1] */
vs_type.width = 32; /* 32-bit float */
vs_type.length = vector_length;
@@ -2060,10 +1702,10 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
fake_buf_ptr = LLVMBuildGEP2(builder, LLVMInt8TypeInContext(context), fake_buf, &bld.zero, 1, "");
/* code generated texture sampling */
- sampler = draw_llvm_sampler_soa_create(draw_llvm_variant_key_samplers(key),
+ sampler = lp_bld_llvm_sampler_soa_create(draw_llvm_variant_key_samplers(key),
MAX2(key->nr_samplers,
key->nr_sampler_views));
- image = draw_llvm_image_soa_create(draw_llvm_variant_key_images(key),
+ image = lp_bld_llvm_image_soa_create(draw_llvm_variant_key_images(key),
key->nr_images);
step = lp_build_const_int32(gallivm, vector_length);
@@ -2075,7 +1717,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
}
have_elts = LLVMBuildICmp(builder, LLVMIntNE,
- LLVMConstPointerNull(arg_types[10]), fetch_elts, "");
+ LLVMConstPointerNull(arg_types[11]), fetch_elts, "");
fetch_max = LLVMBuildSub(builder, count, bld.one, "fetch_max");
fetch_max = lp_build_broadcast_scalar(&blduivec, fetch_max);
@@ -2097,14 +1739,14 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
util_format_get_blocksize(velem->src_format));
LLVMValueRef src_offset = lp_build_const_int32(gallivm,
velem->src_offset);
+ LLVMValueRef src_stride = lp_build_const_int32(gallivm,
+ velem->src_stride);
struct lp_build_if_state if_ctx;
if (velem->src_format != PIPE_FORMAT_NONE) {
vbuffer_ptr = LLVMBuildGEP2(builder, variant->buffer_type, vbuffers_ptr, &vb_index, 1, "");
vb_info = LLVMBuildGEP2(builder, variant->vb_type, vb_ptr, &vb_index, 1, "");
- vb_stride[j] = draw_jit_vbuffer_stride(gallivm, variant->vb_type, vb_info);
- vb_stride[j] = LLVMBuildZExt(gallivm->builder, vb_stride[j],
- LLVMInt32TypeInContext(context), "");
+ vb_stride[j] = src_stride;
vb_buffer_offset = draw_jit_vbuffer_offset(gallivm, variant->vb_type, vb_info);
map_ptr[j] = draw_jit_dvbuffer_map(gallivm, variant->buffer_type, vbuffer_ptr);
buffer_size = draw_jit_dvbuffer_size(gallivm, variant->buffer_type, vbuffer_ptr);
@@ -2245,8 +1887,8 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
LLVMPointerType(LLVMInt8TypeInContext(context),
0), "");
tmp = lp_build_gather(gallivm, vs_type.length,
- 32, bld.type, TRUE,
- fetch_elts, tmp, FALSE);
+ 32, bld.type, true,
+ fetch_elts, tmp, false);
LLVMBuildStore(builder, tmp, index_store);
}
lp_build_else(&if_ctx);
@@ -2315,6 +1957,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
ptr_aos,
&system_values,
context_ptr,
+ resources_ptr,
sampler,
image,
key->clamp_vertex_color,
@@ -2361,8 +2004,8 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant)
}
lp_build_loop_end_cond(&lp_loop, count, step, LLVMIntUGE);
- draw_llvm_sampler_soa_destroy(sampler);
- draw_llvm_image_soa_destroy(image);
+ lp_bld_llvm_sampler_soa_destroy(sampler);
+ lp_bld_llvm_image_soa_destroy(image);
/* return clipping boolean value for function */
ret = clipmask_booli8(gallivm, vs_type, blduivec.vec_type, clipmask_bool_ptr,
@@ -2378,8 +2021,8 @@ struct draw_llvm_variant_key *
draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
{
struct draw_llvm_variant_key *key;
- struct draw_sampler_static_state *draw_sampler;
- struct draw_image_static_state *draw_image;
+ struct lp_sampler_static_state *draw_sampler;
+ struct lp_image_static_state *draw_image;
key = (struct draw_llvm_variant_key *)store;
@@ -2393,7 +2036,7 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
key->bypass_viewport = llvm->draw->bypass_viewport;
key->clip_halfz = llvm->draw->rasterizer->clip_halfz;
/* XXX assumes edgeflag output not at 0 */
- key->need_edgeflags = (llvm->draw->vs.edgeflag_output ? TRUE : FALSE);
+ key->need_edgeflags = (llvm->draw->vs.edgeflag_output ? true : false);
key->ucp_enable = llvm->draw->rasterizer->clip_plane_enable;
key->has_gs_or_tes = llvm->draw->gs.geometry_shader != NULL || llvm->draw->tes.tess_eval_shader != NULL;
key->num_outputs = draw_total_vs_outputs(llvm->draw);
@@ -2467,8 +2110,8 @@ draw_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
void
draw_llvm_dump_variant_key(struct draw_llvm_variant_key *key)
{
- struct draw_sampler_static_state *sampler = draw_llvm_variant_key_samplers(key);
- struct draw_image_static_state *image = draw_llvm_variant_key_images(key);
+ struct lp_sampler_static_state *sampler = draw_llvm_variant_key_samplers(key);
+ struct lp_image_static_state *image = draw_llvm_variant_key_images(key);
debug_printf("clamp_vertex_color = %u\n", key->clamp_vertex_color);
debug_printf("clip_xy = %u\n", key->clip_xy);
debug_printf("clip_z = %u\n", key->clip_z);
@@ -2508,30 +2151,12 @@ draw_llvm_set_mapped_texture(struct draw_context *draw,
uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS],
uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS])
{
- struct draw_jit_texture *jit_tex;
-
- switch (shader_stage) {
- case PIPE_SHADER_VERTEX:
- assert(sview_idx < ARRAY_SIZE(draw->llvm->jit_context.textures));
- jit_tex = &draw->llvm->jit_context.textures[sview_idx];
- break;
- case PIPE_SHADER_GEOMETRY:
- assert(sview_idx < ARRAY_SIZE(draw->llvm->gs_jit_context.textures));
- jit_tex = &draw->llvm->gs_jit_context.textures[sview_idx];
- break;
- case PIPE_SHADER_TESS_CTRL:
- assert(sview_idx < ARRAY_SIZE(draw->llvm->tcs_jit_context.textures));
- jit_tex = &draw->llvm->tcs_jit_context.textures[sview_idx];
- break;
- case PIPE_SHADER_TESS_EVAL:
- assert(sview_idx < ARRAY_SIZE(draw->llvm->tes_jit_context.textures));
- jit_tex = &draw->llvm->tes_jit_context.textures[sview_idx];
- break;
- default:
- assert(0);
- return;
- }
+ struct lp_jit_texture *jit_tex;
+
+ assert(shader_stage < DRAW_MAX_SHADER_STAGE);
+ assert(sview_idx < ARRAY_SIZE(draw->llvm->jit_resources[shader_stage].textures));
+ jit_tex = &draw->llvm->jit_resources[shader_stage].textures[sview_idx];
jit_tex->width = width;
jit_tex->height = height;
jit_tex->depth = depth;
@@ -2560,29 +2185,12 @@ draw_llvm_set_mapped_image(struct draw_context *draw,
uint32_t num_samples,
uint32_t sample_stride)
{
- struct draw_jit_image *jit_image;
-
- switch (shader_stage) {
- case PIPE_SHADER_VERTEX:
- assert(idx < ARRAY_SIZE(draw->llvm->jit_context.images));
- jit_image = &draw->llvm->jit_context.images[idx];
- break;
- case PIPE_SHADER_GEOMETRY:
- assert(idx < ARRAY_SIZE(draw->llvm->gs_jit_context.images));
- jit_image = &draw->llvm->gs_jit_context.images[idx];
- break;
- case PIPE_SHADER_TESS_CTRL:
- assert(idx < ARRAY_SIZE(draw->llvm->tcs_jit_context.images));
- jit_image = &draw->llvm->tcs_jit_context.images[idx];
- break;
- case PIPE_SHADER_TESS_EVAL:
- assert(idx < ARRAY_SIZE(draw->llvm->tes_jit_context.images));
- jit_image = &draw->llvm->tes_jit_context.images[idx];
- break;
- default:
- assert(0);
- return;
- }
+ struct lp_jit_image *jit_image;
+
+ assert(shader_stage < DRAW_MAX_SHADER_STAGE);
+ assert(idx < ARRAY_SIZE(draw->llvm->jit_resources[shader_stage].images));
+
+ jit_image = &draw->llvm->jit_resources[shader_stage].images[idx];
jit_image->width = width;
jit_image->height = height;
@@ -2600,70 +2208,19 @@ void
draw_llvm_set_sampler_state(struct draw_context *draw,
enum pipe_shader_type shader_type)
{
- switch (shader_type) {
- case PIPE_SHADER_VERTEX:
- for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_VERTEX]; i++) {
- struct draw_jit_sampler *jit_sam = &draw->llvm->jit_context.samplers[i];
-
- if (draw->samplers[PIPE_SHADER_VERTEX][i]) {
- const struct pipe_sampler_state *s
- = draw->samplers[PIPE_SHADER_VERTEX][i];
- jit_sam->min_lod = s->min_lod;
- jit_sam->max_lod = s->max_lod;
- jit_sam->lod_bias = s->lod_bias;
- jit_sam->max_aniso = s->max_anisotropy;
- COPY_4V(jit_sam->border_color, s->border_color.f);
- }
- }
- break;
- case PIPE_SHADER_GEOMETRY:
- for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_GEOMETRY]; i++) {
- struct draw_jit_sampler *jit_sam = &draw->llvm->gs_jit_context.samplers[i];
-
- if (draw->samplers[PIPE_SHADER_GEOMETRY][i]) {
- const struct pipe_sampler_state *s
- = draw->samplers[PIPE_SHADER_GEOMETRY][i];
- jit_sam->min_lod = s->min_lod;
- jit_sam->max_lod = s->max_lod;
- jit_sam->lod_bias = s->lod_bias;
- jit_sam->max_aniso = s->max_anisotropy;
- COPY_4V(jit_sam->border_color, s->border_color.f);
- }
- }
- break;
- case PIPE_SHADER_TESS_CTRL:
- for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_TESS_CTRL]; i++) {
- struct draw_jit_sampler *jit_sam = &draw->llvm->tcs_jit_context.samplers[i];
-
- if (draw->samplers[PIPE_SHADER_TESS_CTRL][i]) {
- const struct pipe_sampler_state *s
- = draw->samplers[PIPE_SHADER_TESS_CTRL][i];
- jit_sam->min_lod = s->min_lod;
- jit_sam->max_lod = s->max_lod;
- jit_sam->lod_bias = s->lod_bias;
- jit_sam->max_aniso = s->max_anisotropy;
- COPY_4V(jit_sam->border_color, s->border_color.f);
- }
- }
- break;
- case PIPE_SHADER_TESS_EVAL:
- for (unsigned i = 0; i < draw->num_samplers[PIPE_SHADER_TESS_EVAL]; i++) {
- struct draw_jit_sampler *jit_sam = &draw->llvm->tes_jit_context.samplers[i];
-
- if (draw->samplers[PIPE_SHADER_TESS_EVAL][i]) {
- const struct pipe_sampler_state *s
- = draw->samplers[PIPE_SHADER_TESS_EVAL][i];
- jit_sam->min_lod = s->min_lod;
- jit_sam->max_lod = s->max_lod;
- jit_sam->lod_bias = s->lod_bias;
- jit_sam->max_aniso = s->max_anisotropy;
- COPY_4V(jit_sam->border_color, s->border_color.f);
- }
+ assert(shader_type < DRAW_MAX_SHADER_STAGE);
+ for (unsigned i = 0; i < draw->num_samplers[shader_type]; i++) {
+ struct lp_jit_sampler *jit_sam = &draw->llvm->jit_resources[shader_type].samplers[i];
+
+ if (draw->samplers[shader_type][i]) {
+ const struct pipe_sampler_state *s
+ = draw->samplers[shader_type][i];
+ jit_sam->min_lod = s->min_lod;
+ jit_sam->max_lod = s->max_lod;
+ jit_sam->lod_bias = s->lod_bias;
+ jit_sam->max_aniso = s->max_anisotropy;
+ COPY_4V(jit_sam->border_color, s->border_color.f);
}
- break;
- default:
- assert(0);
- break;
}
}
@@ -2695,21 +2252,14 @@ static void
create_gs_jit_types(struct draw_gs_llvm_variant *var)
{
struct gallivm_state *gallivm = var->gallivm;
- LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
-
- texture_type = create_jit_texture_type(gallivm, "texture");
- sampler_type = create_jit_sampler_type(gallivm, "sampler");
- image_type = create_jit_image_type(gallivm, "image");
- buffer_type = lp_build_create_jit_buffer_type(gallivm);
var->context_type = create_gs_jit_context_type(gallivm,
var->shader->base.vector_length,
- buffer_type,
- texture_type, sampler_type,
- image_type,
"draw_gs_jit_context");
var->context_ptr_type = LLVMPointerType(var->context_type, 0);
+ var->resources_type = lp_build_jit_resources_type(gallivm);
+ var->resources_ptr_type = LLVMPointerType(var->resources_type, 0);
var->input_array_type = create_gs_jit_input_type(gallivm);
}
@@ -2753,10 +2303,11 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
struct gallivm_state *gallivm = variant->gallivm;
LLVMContextRef context = gallivm->context;
LLVMTypeRef int32_type = LLVMInt32TypeInContext(context);
- LLVMTypeRef arg_types[8];
+ LLVMTypeRef arg_types[9];
LLVMTypeRef func_type;
LLVMValueRef variant_func;
LLVMValueRef context_ptr;
+ LLVMValueRef resources_ptr;
LLVMValueRef prim_id_ptr;
LLVMBasicBlockRef block;
LLVMBuilderRef builder;
@@ -2785,13 +2336,14 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
LLVMTypeRef prim_id_type = LLVMVectorType(int32_type, vector_length);
arg_types[0] = get_gs_context_ptr_type(variant); /* context */
- arg_types[1] = variant->input_array_type; /* input */
- arg_types[2] = LLVMPointerType(variant->vertex_header_ptr_type, 0); /* vertex_header */
- arg_types[3] = int32_type; /* num_prims */
- arg_types[4] = int32_type; /* instance_id */
- arg_types[5] = LLVMPointerType(prim_id_type, 0); /* prim_id_ptr */
- arg_types[6] = int32_type;
+ arg_types[1] = variant->resources_ptr_type;
+ arg_types[2] = variant->input_array_type; /* input */
+ arg_types[3] = LLVMPointerType(variant->vertex_header_ptr_type, 0); /* vertex_header */
+ arg_types[4] = int32_type; /* num_prims */
+ arg_types[5] = int32_type; /* instance_id */
+ arg_types[6] = LLVMPointerType(prim_id_type, 0); /* prim_id_ptr */
arg_types[7] = int32_type;
+ arg_types[8] = int32_type;
func_type = LLVMFunctionType(int32_type, arg_types, ARRAY_SIZE(arg_types), 0);
@@ -2808,15 +2360,17 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
if (gallivm->cache && gallivm->cache->data_size)
return;
context_ptr = LLVMGetParam(variant_func, 0);
- input_array = LLVMGetParam(variant_func, 1);
- io_ptr = LLVMGetParam(variant_func, 2);
- num_prims = LLVMGetParam(variant_func, 3);
- system_values.instance_id = LLVMGetParam(variant_func, 4);
- prim_id_ptr = LLVMGetParam(variant_func, 5);
- system_values.invocation_id = LLVMGetParam(variant_func, 6);
- system_values.view_index = LLVMGetParam(variant_func, 7);
+ resources_ptr = LLVMGetParam(variant_func, 1);
+ input_array = LLVMGetParam(variant_func, 2);
+ io_ptr = LLVMGetParam(variant_func, 3);
+ num_prims = LLVMGetParam(variant_func, 4);
+ system_values.instance_id = LLVMGetParam(variant_func, 5);
+ prim_id_ptr = LLVMGetParam(variant_func, 6);
+ system_values.invocation_id = LLVMGetParam(variant_func, 7);
+ system_values.view_index = LLVMGetParam(variant_func, 8);
lp_build_name(context_ptr, "context");
+ lp_build_name(resources_ptr, "resources");
lp_build_name(input_array, "input");
lp_build_name(io_ptr, "io");
lp_build_name(num_prims, "num_prims");
@@ -2847,21 +2401,21 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
lp_build_context_init(&bld, gallivm, lp_type_int(32));
memset(&gs_type, 0, sizeof gs_type);
- gs_type.floating = TRUE; /* floating point values */
- gs_type.sign = TRUE; /* values are signed */
- gs_type.norm = FALSE; /* values are not limited to [0,1] or [-1,1] */
+ gs_type.floating = true; /* floating point values */
+ gs_type.sign = true; /* values are signed */
+ gs_type.norm = false; /* values are not limited to [0,1] or [-1,1] */
gs_type.width = 32; /* 32-bit float */
gs_type.length = vector_length;
- consts_ptr = draw_gs_jit_context_constants(variant, context_ptr);
+ consts_ptr = lp_jit_resources_constants(gallivm, variant->resources_type, resources_ptr);
- ssbos_ptr = draw_gs_jit_context_ssbos(variant, context_ptr);
+ ssbos_ptr = lp_jit_resources_ssbos(gallivm, variant->resources_type, resources_ptr);
/* code generated texture sampling */
- sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
+ sampler = lp_bld_llvm_sampler_soa_create(variant->key.samplers,
MAX2(variant->key.nr_samplers,
variant->key.nr_sampler_views));
- image = draw_llvm_image_soa_create(draw_gs_llvm_variant_key_images(&variant->key),
+ image = lp_bld_llvm_image_soa_create(draw_gs_llvm_variant_key_images(&variant->key),
variant->key.nr_images);
mask_val = generate_mask_value(variant, gs_type);
lp_build_mask_begin(&mask, gallivm, gs_type, mask_val);
@@ -2887,13 +2441,17 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
params.system_values = &system_values;
params.context_type = variant->context_type;
params.context_ptr = context_ptr;
+ params.resources_type = variant->resources_type;
+ params.resources_ptr = resources_ptr;
params.sampler = sampler;
params.info = &llvm->draw->gs.geometry_shader->info;
params.gs_iface = (const struct lp_build_gs_iface *)&gs_iface;
params.ssbo_ptr = ssbos_ptr;
params.image = image;
params.gs_vertex_streams = variant->shader->base.num_vertex_streams;
- params.aniso_filter_table = draw_gs_jit_context_aniso_filter_table(variant, context_ptr);
+ params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm,
+ variant->resources_type,
+ resources_ptr);
if (llvm->draw->gs.geometry_shader->state.type == PIPE_SHADER_IR_TGSI)
lp_build_tgsi_soa(variant->gallivm,
@@ -2906,8 +2464,8 @@ draw_gs_llvm_generate(struct draw_llvm *llvm,
&params,
outputs);
- draw_llvm_sampler_soa_destroy(sampler);
- draw_llvm_image_soa_destroy(image);
+ lp_bld_llvm_sampler_soa_destroy(sampler);
+ lp_bld_llvm_image_soa_destroy(image);
lp_build_mask_end(&mask);
@@ -2961,7 +2519,7 @@ draw_gs_llvm_create_variant(struct draw_llvm *llvm,
create_gs_jit_types(variant);
- variant->vertex_header_type = create_jit_vertex_header(variant->gallivm, num_outputs);
+ variant->vertex_header_type = lp_build_create_jit_vertex_header_type(variant->gallivm, num_outputs);
variant->vertex_header_ptr_type = LLVMPointerType(variant->vertex_header_type, 0);
draw_gs_llvm_generate(llvm, variant);
@@ -3010,8 +2568,8 @@ struct draw_gs_llvm_variant_key *
draw_gs_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
{
struct draw_gs_llvm_variant_key *key;
- struct draw_sampler_static_state *draw_sampler;
- struct draw_image_static_state *draw_image;
+ struct lp_sampler_static_state *draw_sampler;
+ struct lp_image_static_state *draw_image;
key = (struct draw_gs_llvm_variant_key *)store;
@@ -3062,8 +2620,8 @@ draw_gs_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
void
draw_gs_llvm_dump_variant_key(struct draw_gs_llvm_variant_key *key)
{
- struct draw_sampler_static_state *sampler = key->samplers;
- struct draw_image_static_state *image = draw_gs_llvm_variant_key_images(key);
+ struct lp_sampler_static_state *sampler = key->samplers;
+ struct lp_image_static_state *image = draw_gs_llvm_variant_key_images(key);
debug_printf("clamp_vertex_color = %u\n", key->clamp_vertex_color);
for (unsigned i = 0 ; i < key->nr_sampler_views; i++) {
@@ -3081,42 +2639,31 @@ static void
create_tcs_jit_types(struct draw_tcs_llvm_variant *var)
{
struct gallivm_state *gallivm = var->gallivm;
- LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
-
- texture_type = create_jit_texture_type(gallivm, "texture");
- sampler_type = create_jit_sampler_type(gallivm, "sampler");
- image_type = create_jit_image_type(gallivm, "image");
- buffer_type = lp_build_create_jit_buffer_type(gallivm);
-
- var->context_type = create_tcs_jit_context_type(gallivm,
- 0,
- buffer_type,
- texture_type, sampler_type,
- image_type,
- "draw_tcs_jit_context");
+
+ var->resources_type = lp_build_jit_resources_type(gallivm);
+ var->resources_ptr_type = LLVMPointerType(var->resources_type, 0);
var->input_array_type = create_tcs_jit_input_type(gallivm);
var->output_array_type = create_tcs_jit_output_type(gallivm);
- var->context_ptr_type = LLVMPointerType(var->context_type, 0);
}
static LLVMTypeRef
-get_tcs_context_ptr_type(struct draw_tcs_llvm_variant *variant)
+get_tcs_resources_ptr_type(struct draw_tcs_llvm_variant *variant)
{
- if (!variant->context_ptr_type)
+ if (!variant->resources_ptr_type)
create_tcs_jit_types(variant);
- return variant->context_ptr_type;
+ return variant->resources_ptr_type;
}
static LLVMValueRef
draw_tcs_llvm_emit_fetch_input(const struct lp_build_tcs_iface *tes_iface,
struct lp_build_context *bld,
- boolean is_vindex_indirect,
+ bool is_vindex_indirect,
LLVMValueRef vertex_index,
- boolean is_aindex_indirect,
+ bool is_aindex_indirect,
LLVMValueRef attrib_index,
- boolean is_sindex_indirect,
+ bool is_sindex_indirect,
LLVMValueRef swizzle_index)
{
const struct draw_tcs_llvm_iface *tcs = draw_tcs_llvm_iface(tes_iface);
@@ -3173,11 +2720,11 @@ draw_tcs_llvm_emit_fetch_input(const struct lp_build_tcs_iface *tes_iface,
static LLVMValueRef
draw_tcs_llvm_emit_fetch_output(const struct lp_build_tcs_iface *tes_iface,
struct lp_build_context *bld,
- boolean is_vindex_indirect,
+ bool is_vindex_indirect,
LLVMValueRef vertex_index,
- boolean is_aindex_indirect,
+ bool is_aindex_indirect,
LLVMValueRef attrib_index,
- boolean is_sindex_indirect,
+ bool is_sindex_indirect,
LLVMValueRef swizzle_index,
uint32_t name)
{
@@ -3238,11 +2785,11 @@ static void
draw_tcs_llvm_emit_store_output(const struct lp_build_tcs_iface *tes_iface,
struct lp_build_context *bld,
unsigned name,
- boolean is_vindex_indirect,
+ bool is_vindex_indirect,
LLVMValueRef vertex_index,
- boolean is_aindex_indirect,
+ bool is_aindex_indirect,
LLVMValueRef attrib_index,
- boolean is_sindex_indirect,
+ bool is_sindex_indirect,
LLVMValueRef swizzle_index,
LLVMValueRef value,
LLVMValueRef mask_vec)
@@ -3345,7 +2892,7 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
LLVMTypeRef arg_types[7];
LLVMTypeRef func_type, coro_func_type;
LLVMValueRef variant_func, variant_coro;
- LLVMValueRef context_ptr;
+ LLVMValueRef resources_ptr;
LLVMValueRef view_index;
LLVMValueRef input_array, output_array, prim_id, patch_vertices_in;
LLVMValueRef mask_val;
@@ -3369,7 +2916,7 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
snprintf(func_name_coro, sizeof(func_name_coro), "draw_llvm_tcs_coro_variant");
- arg_types[0] = get_tcs_context_ptr_type(variant); /* context */
+ arg_types[0] = get_tcs_resources_ptr_type(variant); /* context */
arg_types[1] = variant->input_array_type; /* input */
arg_types[2] = variant->output_array_type;
arg_types[3] = int32_type;
@@ -3401,14 +2948,14 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
if (gallivm->cache && gallivm->cache->data_size)
return;
- context_ptr = LLVMGetParam(variant_func, 0);
+ resources_ptr = LLVMGetParam(variant_func, 0);
input_array = LLVMGetParam(variant_func, 1);
output_array = LLVMGetParam(variant_func, 2);
prim_id = LLVMGetParam(variant_func, 3);
patch_vertices_in = LLVMGetParam(variant_func, 4);
view_index = LLVMGetParam(variant_func, 5);
- lp_build_name(context_ptr, "context");
+ lp_build_name(resources_ptr, "resources");
lp_build_name(input_array, "input");
lp_build_name(output_array, "output");
lp_build_name(prim_id, "prim_id");
@@ -3422,9 +2969,9 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
lp_build_context_init(&bld, gallivm, lp_type_int(32));
memset(&tcs_type, 0, sizeof tcs_type);
- tcs_type.floating = TRUE; /* floating point values */
- tcs_type.sign = TRUE; /* values are signed */
- tcs_type.norm = FALSE; /* values are not limited to [0,1] or [-1,1] */
+ tcs_type.floating = true; /* floating point values */
+ tcs_type.sign = true; /* values are signed */
+ tcs_type.norm = false; /* values are not limited to [0,1] or [-1,1] */
tcs_type.width = 32; /* 32-bit float */
tcs_type.length = vector_length;
@@ -3446,7 +2993,7 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
lp_build_const_int32(gallivm, 0)); /* inner loop */
{
LLVMValueRef args[7];
- args[0] = context_ptr;
+ args[0] = resources_ptr;
args[1] = input_array;
args[2] = output_array;
args[3] = prim_id;
@@ -3489,20 +3036,20 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
block = LLVMAppendBasicBlockInContext(gallivm->context, variant_coro, "entry");
LLVMPositionBuilderAtEnd(builder, block);
- context_ptr = LLVMGetParam(variant_coro, 0);
+ resources_ptr = LLVMGetParam(variant_coro, 0);
input_array = LLVMGetParam(variant_coro, 1);
output_array = LLVMGetParam(variant_coro, 2);
prim_id = LLVMGetParam(variant_coro, 3);
patch_vertices_in = LLVMGetParam(variant_coro, 4);
view_index = LLVMGetParam(variant_coro, 5);
- consts_ptr = draw_tcs_jit_context_constants(variant, context_ptr);
+ consts_ptr = lp_jit_resources_constants(gallivm, variant->resources_type, resources_ptr);
- ssbos_ptr = draw_tcs_jit_context_ssbos(variant, context_ptr);
- sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
+ ssbos_ptr = lp_jit_resources_ssbos(gallivm, variant->resources_type, resources_ptr);
+ sampler = lp_bld_llvm_sampler_soa_create(variant->key.samplers,
MAX2(variant->key.nr_samplers,
variant->key.nr_sampler_views));
- image = draw_llvm_image_soa_create(draw_tcs_llvm_variant_key_images(&variant->key),
+ image = lp_bld_llvm_image_soa_create(draw_tcs_llvm_variant_key_images(&variant->key),
variant->key.nr_images);
LLVMValueRef counter = LLVMGetParam(variant_coro, 6);
@@ -3546,15 +3093,17 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
params.mask = &mask;
params.consts_ptr = consts_ptr;
params.system_values = &system_values;
- params.context_type = variant->context_type;
- params.context_ptr = context_ptr;
+ params.resources_type = variant->resources_type;
+ params.resources_ptr = resources_ptr;
params.sampler = sampler;
params.info = &llvm->draw->tcs.tess_ctrl_shader->info;
params.ssbo_ptr = ssbos_ptr;
params.image = image;
params.coro = &coro_info;
params.tcs_iface = &tcs_iface.base;
- params.aniso_filter_table = draw_tcs_jit_context_aniso_filter_table(variant, context_ptr);
+ params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm,
+ variant->resources_type,
+ resources_ptr);
lp_build_nir_soa(variant->gallivm,
llvm->draw->tcs.tess_ctrl_shader->state.ir.nir,
@@ -3574,8 +3123,8 @@ draw_tcs_llvm_generate(struct draw_llvm *llvm,
LLVMBuildRet(builder, coro_hdl);
}
- draw_llvm_sampler_soa_destroy(sampler);
- draw_llvm_image_soa_destroy(image);
+ lp_bld_llvm_sampler_soa_destroy(sampler);
+ lp_bld_llvm_image_soa_destroy(image);
gallivm_verify_function(gallivm, variant_func);
gallivm_verify_function(gallivm, variant_coro);
}
@@ -3676,8 +3225,8 @@ draw_tcs_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
{
unsigned i;
struct draw_tcs_llvm_variant_key *key;
- struct draw_sampler_static_state *draw_sampler;
- struct draw_image_static_state *draw_image;
+ struct lp_sampler_static_state *draw_sampler;
+ struct lp_image_static_state *draw_image;
key = (struct draw_tcs_llvm_variant_key *)store;
@@ -3724,8 +3273,8 @@ draw_tcs_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
void
draw_tcs_llvm_dump_variant_key(struct draw_tcs_llvm_variant_key *key)
{
- struct draw_sampler_static_state *sampler = key->samplers;
- struct draw_image_static_state *image = draw_tcs_llvm_variant_key_images(key);
+ struct lp_sampler_static_state *sampler = key->samplers;
+ struct lp_image_static_state *image = draw_tcs_llvm_variant_key_images(key);
for (unsigned i = 0 ; i < key->nr_sampler_views; i++) {
debug_printf("sampler[%i].src_format = %s\n", i,
util_format_name(sampler[i].texture_state.format));
@@ -3740,32 +3289,20 @@ static void
create_tes_jit_types(struct draw_tes_llvm_variant *var)
{
struct gallivm_state *gallivm = var->gallivm;
- LLVMTypeRef texture_type, sampler_type, image_type, buffer_type;
-
- texture_type = create_jit_texture_type(gallivm, "texture");
- sampler_type = create_jit_sampler_type(gallivm, "sampler");
- image_type = create_jit_image_type(gallivm, "image");
- buffer_type = lp_build_create_jit_buffer_type(gallivm);
-
- var->context_type = create_tes_jit_context_type(gallivm,
- 0,
- buffer_type,
- texture_type, sampler_type,
- image_type,
- "draw_tes_jit_context");
- var->context_ptr_type = LLVMPointerType(var->context_type, 0);
+ var->resources_type = lp_build_jit_resources_type(gallivm);
+ var->resources_ptr_type = LLVMPointerType(var->resources_type, 0);
var->input_array_deref_type = create_tes_jit_input_deref_type(gallivm);
var->input_array_type = LLVMPointerType(var->input_array_deref_type, 0); /* num vertices per prim */
}
static LLVMTypeRef
-get_tes_context_ptr_type(struct draw_tes_llvm_variant *variant)
+get_tes_resources_ptr_type(struct draw_tes_llvm_variant *variant)
{
- if (!variant->context_ptr_type)
+ if (!variant->resources_ptr_type)
create_tes_jit_types(variant);
- return variant->context_ptr_type;
+ return variant->resources_ptr_type;
}
@@ -3795,11 +3332,11 @@ generate_tes_mask_value(struct draw_tes_llvm_variant *variant,
static LLVMValueRef
draw_tes_llvm_fetch_vertex_input(const struct lp_build_tes_iface *tes_iface,
struct lp_build_context *bld,
- boolean is_vindex_indirect,
+ bool is_vindex_indirect,
LLVMValueRef vertex_index,
- boolean is_aindex_indirect,
+ bool is_aindex_indirect,
LLVMValueRef attrib_index,
- boolean is_sindex_indirect,
+ bool is_sindex_indirect,
LLVMValueRef swizzle_index)
{
const struct draw_tes_llvm_iface *tes = draw_tes_llvm_iface(tes_iface);
@@ -3857,7 +3394,7 @@ draw_tes_llvm_fetch_vertex_input(const struct lp_build_tes_iface *tes_iface,
static LLVMValueRef
draw_tes_llvm_fetch_patch_input(const struct lp_build_tes_iface *tes_iface,
struct lp_build_context *bld,
- boolean is_aindex_indirect,
+ bool is_aindex_indirect,
LLVMValueRef attrib_index,
LLVMValueRef swizzle_index)
{
@@ -3914,7 +3451,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
LLVMTypeRef arg_types[11];
LLVMTypeRef func_type;
LLVMValueRef variant_func;
- LLVMValueRef context_ptr;
+ LLVMValueRef resources_ptr;
LLVMValueRef tess_coord[2], io_ptr, input_array, num_tess_coord;
LLVMValueRef view_index;
LLVMValueRef tess_inner, tess_outer, prim_id, patch_vertices_in;
@@ -3945,7 +3482,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
LLVMTypeRef tess_outer_deref_type = LLVMArrayType(flt_type, 4);
LLVMTypeRef tess_inner_deref_type = LLVMArrayType(flt_type, 2);
- arg_types[0] = get_tes_context_ptr_type(variant); /* context */
+ arg_types[0] = get_tes_resources_ptr_type(variant); /* context */
arg_types[1] = variant->input_array_type; /* input */
arg_types[2] = variant->vertex_header_ptr_type;
arg_types[3] = int32_type;
@@ -3969,7 +3506,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
if (gallivm->cache && gallivm->cache->data_size)
return;
- context_ptr = LLVMGetParam(variant_func, 0);
+ resources_ptr = LLVMGetParam(variant_func, 0);
input_array = LLVMGetParam(variant_func, 1);
io_ptr = LLVMGetParam(variant_func, 2);
prim_id = LLVMGetParam(variant_func, 3);
@@ -3981,7 +3518,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
patch_vertices_in = LLVMGetParam(variant_func, 9);
view_index = LLVMGetParam(variant_func, 10);
- lp_build_name(context_ptr, "context");
+ lp_build_name(resources_ptr, "resources");
lp_build_name(input_array, "input");
lp_build_name(io_ptr, "io");
lp_build_name(prim_id, "prim_id");
@@ -4005,21 +3542,21 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
lp_build_context_init(&bld, gallivm, lp_type_int(32));
memset(&tes_type, 0, sizeof tes_type);
- tes_type.floating = TRUE; /* floating point values */
- tes_type.sign = TRUE; /* values are signed */
- tes_type.norm = FALSE; /* values are not limited to [0,1] or [-1,1] */
+ tes_type.floating = true; /* floating point values */
+ tes_type.sign = true; /* values are signed */
+ tes_type.norm = false; /* values are not limited to [0,1] or [-1,1] */
tes_type.width = 32; /* 32-bit float */
tes_type.length = vector_length;
lp_build_context_init(&bldvec, variant->gallivm, lp_int_type(tes_type));
- consts_ptr = draw_tes_jit_context_constants(variant, context_ptr);
+ consts_ptr = lp_jit_resources_constants(gallivm, variant->resources_type, resources_ptr);
- ssbos_ptr = draw_tes_jit_context_ssbos(variant, context_ptr);
+ ssbos_ptr = lp_jit_resources_ssbos(gallivm, variant->resources_type, resources_ptr);
- sampler = draw_llvm_sampler_soa_create(variant->key.samplers,
+ sampler = lp_bld_llvm_sampler_soa_create(variant->key.samplers,
MAX2(variant->key.nr_samplers,
variant->key.nr_sampler_views));
- image = draw_llvm_image_soa_create(draw_tes_llvm_variant_key_images(&variant->key),
+ image = lp_bld_llvm_image_soa_create(draw_tes_llvm_variant_key_images(&variant->key),
variant->key.nr_images);
step = lp_build_const_int32(gallivm, vector_length);
@@ -4056,7 +3593,7 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
LLVMValueRef idx = LLVMBuildAdd(builder, lp_loop.counter, lp_build_const_int32(gallivm, j), "");
LLVMValueRef tc_val;
if (i == 2) {
- if (variant->shader->base.prim_mode == PIPE_PRIM_TRIANGLES) {
+ if (variant->shader->base.prim_mode == MESA_PRIM_TRIANGLES) {
tc_val = lp_build_const_float(gallivm, 1.0);
tc_val = LLVMBuildFSub(builder, tc_val, lp_build_pointer_get2(builder, flt_type, tess_coord[0], idx), "");
tc_val = LLVMBuildFSub(builder, tc_val, lp_build_pointer_get2(builder, flt_type, tess_coord[1], idx), "");
@@ -4077,14 +3614,14 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
params.mask = &mask;
params.consts_ptr = consts_ptr;
params.system_values = &system_values;
- params.context_type = variant->context_type;
- params.context_ptr = context_ptr;
+ params.resources_type = variant->resources_type;
+ params.resources_ptr = resources_ptr;
params.sampler = sampler;
params.info = &llvm->draw->tes.tess_eval_shader->info;
params.ssbo_ptr = ssbos_ptr;
params.image = image;
params.tes_iface = &tes_iface.base;
- params.aniso_filter_table = draw_tes_jit_context_aniso_filter_table(variant, context_ptr);
+ params.aniso_filter_table = lp_jit_resources_aniso_filter_table(gallivm, variant->resources_type, resources_ptr);
lp_build_nir_soa(variant->gallivm,
llvm->draw->tes.tess_eval_shader->state.ir.nir,
@@ -4103,11 +3640,11 @@ draw_tes_llvm_generate(struct draw_llvm *llvm,
lp_int_type(tes_type), 0);
convert_to_aos(gallivm, variant->vertex_header_type, io, NULL, outputs, clipmask,
- draw_total_tes_outputs(llvm->draw), tes_type, primid_slot, FALSE);
+ draw_total_tes_outputs(llvm->draw), tes_type, primid_slot, false);
}
lp_build_loop_end_cond(&lp_loop, num_tess_coord, step, LLVMIntUGE);
- draw_llvm_sampler_soa_destroy(sampler);
- draw_llvm_image_soa_destroy(image);
+ lp_bld_llvm_sampler_soa_destroy(sampler);
+ lp_bld_llvm_image_soa_destroy(image);
LLVMBuildRet(builder, lp_build_zero(gallivm, lp_type_uint(32)));
gallivm_verify_function(gallivm, variant_func);
@@ -4155,7 +3692,7 @@ draw_tes_llvm_create_variant(struct draw_llvm *llvm,
create_tes_jit_types(variant);
- variant->vertex_header_type = create_jit_vertex_header(variant->gallivm, num_outputs);
+ variant->vertex_header_type = lp_build_create_jit_vertex_header_type(variant->gallivm, num_outputs);
variant->vertex_header_ptr_type = LLVMPointerType(variant->vertex_header_type, 0);
if (gallivm_debug & (GALLIVM_DEBUG_TGSI | GALLIVM_DEBUG_IR)) {
@@ -4209,8 +3746,8 @@ struct draw_tes_llvm_variant_key *
draw_tes_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
{
struct draw_tes_llvm_variant_key *key;
- struct draw_sampler_static_state *draw_sampler;
- struct draw_image_static_state *draw_image;
+ struct lp_sampler_static_state *draw_sampler;
+ struct lp_image_static_state *draw_image;
key = (struct draw_tes_llvm_variant_key *)store;
@@ -4266,8 +3803,8 @@ draw_tes_llvm_make_variant_key(struct draw_llvm *llvm, char *store)
void
draw_tes_llvm_dump_variant_key(struct draw_tes_llvm_variant_key *key)
{
- struct draw_sampler_static_state *sampler = key->samplers;
- struct draw_image_static_state *image = draw_tes_llvm_variant_key_images(key);
+ struct lp_sampler_static_state *sampler = key->samplers;
+ struct lp_image_static_state *image = draw_tes_llvm_variant_key_images(key);
if (key->primid_needed)
debug_printf("prim id output %d\n", key->primid_output);
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_llvm.h b/lib/mesa/src/gallium/auxiliary/draw/draw_llvm.h
index f82a6a611..65199feab 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_llvm.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_llvm.h
@@ -37,6 +37,7 @@
#include "gallivm/lp_bld_sample.h"
#include "gallivm/lp_bld_limits.h"
#include "gallivm/lp_bld_jit_types.h"
+#include "gallivm/lp_bld_jit_sample.h"
#include "pipe/p_context.h"
#include "util/list.h"
@@ -48,105 +49,6 @@ struct llvm_geometry_shader;
struct llvm_tess_ctrl_shader;
struct llvm_tess_eval_shader;
-struct draw_jit_texture
-{
- uint32_t width;
- uint32_t height;
- uint32_t depth;
- const void *base;
- uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS];
- uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS];
- uint32_t first_level;
- uint32_t last_level;
- uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS];
- uint32_t num_samples;
- uint32_t sample_stride;
-};
-
-
-struct draw_sampler_static_state
-{
- /*
- * These attributes are effectively interleaved for more sane key handling.
- * However, there might be lots of null space if the amount of samplers and
- * textures isn't the same.
- */
- struct lp_static_sampler_state sampler_state;
- struct lp_static_texture_state texture_state;
-};
-
-struct draw_image_static_state
-{
- struct lp_static_texture_state image_state;
-};
-
-
-struct draw_jit_sampler
-{
- float min_lod;
- float max_lod;
- float lod_bias;
- float border_color[4];
- float max_aniso;
-};
-
-
-struct draw_jit_image
-{
- uint32_t width;
- uint32_t height;
- uint32_t depth;
- const void *base;
- uint32_t row_stride;
- uint32_t img_stride;
- uint32_t num_samples;
- uint32_t sample_stride;
-};
-
-enum {
- DRAW_JIT_TEXTURE_WIDTH = 0,
- DRAW_JIT_TEXTURE_HEIGHT,
- DRAW_JIT_TEXTURE_DEPTH,
- DRAW_JIT_TEXTURE_BASE,
- DRAW_JIT_TEXTURE_ROW_STRIDE,
- DRAW_JIT_TEXTURE_IMG_STRIDE,
- DRAW_JIT_TEXTURE_FIRST_LEVEL,
- DRAW_JIT_TEXTURE_LAST_LEVEL,
- DRAW_JIT_TEXTURE_MIP_OFFSETS,
- DRAW_JIT_TEXTURE_NUM_SAMPLES,
- DRAW_JIT_TEXTURE_SAMPLE_STRIDE,
- DRAW_JIT_TEXTURE_NUM_FIELDS /* number of fields above */
-};
-
-
-enum {
- DRAW_JIT_SAMPLER_MIN_LOD,
- DRAW_JIT_SAMPLER_MAX_LOD,
- DRAW_JIT_SAMPLER_LOD_BIAS,
- DRAW_JIT_SAMPLER_BORDER_COLOR,
- DRAW_JIT_SAMPLER_MAX_ANISO,
- DRAW_JIT_SAMPLER_NUM_FIELDS /* number of fields above */
-};
-
-
-enum {
- DRAW_JIT_VERTEX_VERTEX_ID = 0,
- DRAW_JIT_VERTEX_CLIP_POS,
- DRAW_JIT_VERTEX_DATA
-};
-
-enum {
- DRAW_JIT_IMAGE_WIDTH = 0,
- DRAW_JIT_IMAGE_HEIGHT,
- DRAW_JIT_IMAGE_DEPTH,
- DRAW_JIT_IMAGE_BASE,
- DRAW_JIT_IMAGE_ROW_STRIDE,
- DRAW_JIT_IMAGE_IMG_STRIDE,
- DRAW_JIT_IMAGE_NUM_SAMPLES,
- DRAW_JIT_IMAGE_SAMPLE_STRIDE,
- DRAW_JIT_IMAGE_NUM_FIELDS /* number of fields above */
-};
-
/**
* This structure is passed directly to the generated vertex shader.
*
@@ -158,64 +60,27 @@ enum {
* Only use types with a clear size and padding here, in particular prefer the
* stdint.h types to the basic integer types.
*/
-struct draw_jit_context
+struct draw_vs_jit_context
{
- struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
float (*planes) [DRAW_TOTAL_CLIP_PLANES][4];
struct pipe_viewport_state *viewports;
-
- struct draw_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
- struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
- struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
-
- struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
-
- const float *aniso_filter_table;
};
enum {
- DRAW_JIT_CTX_CONSTANTS = 0,
- DRAW_JIT_CTX_PLANES = 1,
- DRAW_JIT_CTX_VIEWPORT = 2,
- DRAW_JIT_CTX_TEXTURES = 3,
- DRAW_JIT_CTX_SAMPLERS = 4,
- DRAW_JIT_CTX_IMAGES = 5,
- DRAW_JIT_CTX_SSBOS = 6,
- DRAW_JIT_CTX_ANISO_FILTER_TABLE = 7,
- DRAW_JIT_CTX_NUM_FIELDS
+ DRAW_VS_JIT_CTX_PLANES = 0,
+ DRAW_VS_JIT_CTX_VIEWPORT = 1,
+ DRAW_VS_JIT_CTX_NUM_FIELDS
};
-#define draw_jit_context_constants(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_CONSTANTS, "constants")
-
-#define draw_jit_context_planes(_gallivm, _type, _ptr) \
- lp_build_struct_get2(_gallivm, _type, _ptr, DRAW_JIT_CTX_PLANES, "planes")
-
-#define draw_jit_context_viewports(_variant, _ptr) \
- lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_VIEWPORT, "viewports")
-
-#define draw_jit_context_ssbos(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_SSBOS, "ssbos")
-
-#define draw_jit_context_aniso_filter_table(_variant, _ptr) \
- lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
-
-
-#define draw_jit_header_id(_gallivm, _type, _ptr) \
- lp_build_struct_get_ptr2(_gallivm, _type, _ptr, DRAW_JIT_VERTEX_VERTEX_ID, "id")
-
-#define draw_jit_header_clip_pos(_gallivm, _type, _ptr) \
- lp_build_struct_get_ptr2(_gallivm, _type, _ptr, DRAW_JIT_VERTEX_CLIP_POS, "clip_pos")
+#define draw_vs_jit_context_planes(_gallivm, _type, _ptr) \
+ lp_build_struct_get2(_gallivm, _type, _ptr, DRAW_VS_JIT_CTX_PLANES, "planes")
-#define draw_jit_header_data(_gallivm, _type, _ptr) \
- lp_build_struct_get_ptr2(_gallivm, _type, _ptr, DRAW_JIT_VERTEX_DATA, "data")
+#define draw_vs_jit_context_viewports(_variant, _ptr) \
+ lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_VS_JIT_CTX_VIEWPORT, "viewports")
-#define draw_jit_vbuffer_stride(_gallivm, _type, _ptr) \
- lp_build_struct_get2(_gallivm, _type, _ptr, 0, "stride")
-
#define draw_jit_vbuffer_offset(_gallivm, _type, _ptr) \
- lp_build_struct_get2(_gallivm, _type, _ptr, 2, "buffer_offset")
+ lp_build_struct_get2(_gallivm, _type, _ptr, 1, "buffer_offset")
enum {
DRAW_JIT_DVBUFFER_MAP = 0,
@@ -243,45 +108,28 @@ enum {
*/
struct draw_gs_jit_context
{
- struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
float (*planes) [DRAW_TOTAL_CLIP_PLANES][4];
struct pipe_viewport_state *viewports;
- /* There two need to be exactly at DRAW_JIT_CTX_TEXTURES and
- * DRAW_JIT_CTX_SAMPLERS positions in the struct */
- struct draw_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
- struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
- struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
-
int **prim_lengths;
int *emitted_vertices;
int *emitted_prims;
- struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
-
- const float *aniso_filter_table;
};
enum {
- DRAW_GS_JIT_CTX_CONSTANTS = 0,
- DRAW_GS_JIT_CTX_PLANES = 1,
- DRAW_GS_JIT_CTX_VIEWPORT = 2,
- /* Textures and samples are reserved for DRAW_JIT_CTX_TEXTURES
- * and DRAW_JIT_CTX_SAMPLERS, because they both need
- * to be at exactly the same locations as they are in the
- * VS ctx structure for sampling to work. */
- DRAW_GS_JIT_CTX_TEXTURES = DRAW_JIT_CTX_TEXTURES,
- DRAW_GS_JIT_CTX_SAMPLERS = DRAW_JIT_CTX_SAMPLERS,
- DRAW_GS_JIT_CTX_IMAGES = DRAW_JIT_CTX_IMAGES,
- DRAW_GS_JIT_CTX_PRIM_LENGTHS = 6,
- DRAW_GS_JIT_CTX_EMITTED_VERTICES = 7,
- DRAW_GS_JIT_CTX_EMITTED_PRIMS = 8,
- DRAW_GS_JIT_CTX_SSBOS = 9,
- DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE = 10,
- DRAW_GS_JIT_CTX_NUM_FIELDS = 11
+ DRAW_GS_JIT_CTX_PLANES = 0,
+ DRAW_GS_JIT_CTX_VIEWPORT = 1,
+ DRAW_GS_JIT_CTX_PRIM_LENGTHS = 2,
+ DRAW_GS_JIT_CTX_EMITTED_VERTICES = 3,
+ DRAW_GS_JIT_CTX_EMITTED_PRIMS = 4,
+ DRAW_GS_JIT_CTX_NUM_FIELDS = 5
};
-#define draw_gs_jit_context_constants(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_CONSTANTS, "constants")
+#define draw_gs_jit_context_planes(_gallivm, _ptr) \
+ lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_PLANES, "planes")
+
+#define draw_gs_jit_context_viewports(_gallivm, _ptr) \
+ lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_VIEWPORT, "viewports")
#define draw_gs_jit_prim_lengths(_variant, _ptr) \
lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_PRIM_LENGTHS, "prim_lengths")
@@ -292,88 +140,10 @@ enum {
#define draw_gs_jit_emitted_prims(_variant, _ptr) \
lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_EMITTED_PRIMS, "emitted_prims")
-#define draw_gs_jit_context_ssbos(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_SSBOS, "ssbos")
-
-#define draw_gs_jit_context_aniso_filter_table(_variant, _ptr) \
- lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_GS_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
-
-struct draw_tcs_jit_context {
- struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
-
- int dummy1;
- int dummy2;
- /* There two need to be exactly at DRAW_JIT_CTX_TEXTURES and
- * DRAW_JIT_CTX_SAMPLERS positions in the struct */
- struct draw_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
- struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
- struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
-
- struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
-
- const float *aniso_filter_table;
-};
-
-enum {
- DRAW_TCS_JIT_CTX_CONSTANTS = 0,
- DRAW_TCS_JIT_CTX_DUMMY1 = 1,
- DRAW_TCS_JIT_CTX_DUMMY2 = 2,
- DRAW_TCS_JIT_CTX_TEXTURES = DRAW_JIT_CTX_TEXTURES,
- DRAW_TCS_JIT_CTX_SAMPLERS = DRAW_JIT_CTX_SAMPLERS,
- DRAW_TCS_JIT_CTX_IMAGES = DRAW_JIT_CTX_IMAGES,
- DRAW_TCS_JIT_CTX_SSBOS = 6,
- DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE = 7,
- DRAW_TCS_JIT_CTX_NUM_FIELDS = 8,
-};
-
-#define draw_tcs_jit_context_constants(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_CONSTANTS, "constants")
-
-#define draw_tcs_jit_context_ssbos(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_SSBOS, "ssbos")
-
-#define draw_tcs_jit_context_aniso_filter_table(_variant, _ptr) \
- lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TCS_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
-
-struct draw_tes_jit_context {
- struct lp_jit_buffer constants[LP_MAX_TGSI_CONST_BUFFERS];
- int dummy1;
- int dummy2;
- /* There two need to be exactly at DRAW_JIT_CTX_TEXTURES and
- * DRAW_JIT_CTX_SAMPLERS positions in the struct */
- struct draw_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS];
- struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS];
- struct draw_jit_image images[PIPE_MAX_SHADER_IMAGES];
-
- struct lp_jit_buffer ssbos[LP_MAX_TGSI_SHADER_BUFFERS];
-
- const float *aniso_filter_table;
-};
-
-enum {
- DRAW_TES_JIT_CTX_CONSTANTS = 0,
- DRAW_TES_JIT_CTX_DUMMY1 = 1,
- DRAW_TES_JIT_CTX_DUMMY2 = 2,
- DRAW_TES_JIT_CTX_TEXTURES = DRAW_JIT_CTX_TEXTURES,
- DRAW_TES_JIT_CTX_SAMPLERS = DRAW_JIT_CTX_SAMPLERS,
- DRAW_TES_JIT_CTX_IMAGES = DRAW_JIT_CTX_IMAGES,
- DRAW_TES_JIT_CTX_SSBOS = 6,
- DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE = 7,
- DRAW_TES_JIT_CTX_NUM_FIELDS = 8,
-};
-
-#define draw_tes_jit_context_constants(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_CONSTANTS, "constants")
-
-#define draw_tes_jit_context_ssbos(_variant, _ptr) \
- lp_build_struct_get_ptr2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_SSBOS, "ssbos")
-
-#define draw_tes_jit_context_aniso_filter_table(_variant, _ptr) \
- lp_build_struct_get2(_variant->gallivm, _variant->context_type, _ptr, DRAW_TES_JIT_CTX_ANISO_FILTER_TABLE, "aniso_filter_table")
-
-typedef boolean
-(*draw_jit_vert_func)(struct draw_jit_context *context,
+typedef bool
+(*draw_jit_vert_func)(struct draw_vs_jit_context *context,
+ const struct lp_jit_resources *resources,
struct vertex_header *io,
const struct draw_vertex_buffer vbuffers[PIPE_MAX_ATTRIBS],
unsigned count,
@@ -389,6 +159,7 @@ typedef boolean
typedef int
(*draw_gs_jit_func)(struct draw_gs_jit_context *context,
+ const struct lp_jit_resources *resources,
float inputs[6][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS][TGSI_NUM_CHANNELS],
struct vertex_header **output,
unsigned num_prims,
@@ -398,14 +169,14 @@ typedef int
unsigned view_id);
typedef int
-(*draw_tcs_jit_func)(struct draw_tcs_jit_context *context,
+(*draw_tcs_jit_func)(const struct lp_jit_resources *resources,
float inputs[32][NUM_TCS_INPUTS][TGSI_NUM_CHANNELS],
float outputs[32][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS],
uint32_t prim_id, uint32_t patch_vertices_in,
unsigned view_id);
typedef int
-(*draw_tes_jit_func)(struct draw_tes_jit_context *context,
+(*draw_tes_jit_func)(const struct lp_jit_resources *resources,
float inputs[32][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS],
struct vertex_header *io,
uint32_t prim_id, uint32_t num_tess_coord,
@@ -451,7 +222,7 @@ struct draw_gs_llvm_variant_key
unsigned num_outputs:8;
/* note padding here - must use memset */
unsigned clamp_vertex_color:1;
- struct draw_sampler_static_state samplers[1];
+ struct lp_sampler_static_state samplers[1];
/* Followed by variable number of images.*/
};
@@ -460,7 +231,7 @@ struct draw_tcs_llvm_variant_key
unsigned nr_samplers:8;
unsigned nr_sampler_views:8;
unsigned nr_images:8;
- struct draw_sampler_static_state samplers[1];
+ struct lp_sampler_static_state samplers[1];
/* Followed by variable number of images.*/
};
@@ -472,30 +243,30 @@ struct draw_tes_llvm_variant_key
unsigned primid_output:7;
unsigned primid_needed:1;
unsigned clamp_vertex_color:1;
- struct draw_sampler_static_state samplers[1];
+ struct lp_sampler_static_state samplers[1];
/* Followed by variable number of images.*/
};
#define DRAW_LLVM_MAX_VARIANT_KEY_SIZE \
(sizeof(struct draw_llvm_variant_key) + \
- PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state) + \
- PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \
+ PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct lp_sampler_static_state) + \
+ PIPE_MAX_SHADER_IMAGES * sizeof(struct lp_image_static_state) + \
(PIPE_MAX_ATTRIBS-1) * sizeof(struct pipe_vertex_element))
#define DRAW_GS_LLVM_MAX_VARIANT_KEY_SIZE \
(sizeof(struct draw_gs_llvm_variant_key) + \
- PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \
- PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state))
+ PIPE_MAX_SHADER_IMAGES * sizeof(struct lp_image_static_state) + \
+ PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct lp_sampler_static_state))
#define DRAW_TCS_LLVM_MAX_VARIANT_KEY_SIZE \
(sizeof(struct draw_tcs_llvm_variant_key) + \
- PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \
- PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state))
+ PIPE_MAX_SHADER_IMAGES * sizeof(struct lp_image_static_state) + \
+ PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct lp_sampler_static_state))
#define DRAW_TES_LLVM_MAX_VARIANT_KEY_SIZE \
(sizeof(struct draw_tes_llvm_variant_key) + \
- PIPE_MAX_SHADER_IMAGES * sizeof(struct draw_image_static_state) + \
- PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state))
+ PIPE_MAX_SHADER_IMAGES * sizeof(struct lp_image_static_state) + \
+ PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct lp_sampler_static_state))
static inline size_t
@@ -507,8 +278,8 @@ draw_llvm_variant_key_size(unsigned nr_vertex_elements,
return (sizeof(struct draw_llvm_variant_key) +
(nr_vertex_elements - 1) * sizeof(struct pipe_vertex_element) +
MAX2(nr_samplers, nr_sampler_views) *
- sizeof(struct draw_sampler_static_state) +
- nr_images * sizeof(struct draw_image_static_state));
+ sizeof(struct lp_sampler_static_state) +
+ nr_images * sizeof(struct lp_image_static_state));
}
@@ -519,8 +290,8 @@ draw_gs_llvm_variant_key_size(unsigned nr_samplers,
{
return (sizeof(struct draw_gs_llvm_variant_key) +
(MAX2(nr_samplers, nr_sampler_views) - 1) *
- sizeof(struct draw_sampler_static_state) +
- nr_images * sizeof(struct draw_sampler_static_state));
+ sizeof(struct lp_sampler_static_state) +
+ nr_images * sizeof(struct lp_sampler_static_state));
}
static inline size_t
@@ -530,8 +301,8 @@ draw_tcs_llvm_variant_key_size(unsigned nr_samplers,
{
return (sizeof(struct draw_tcs_llvm_variant_key) +
(MAX2(nr_samplers, nr_sampler_views) - 1) *
- sizeof(struct draw_sampler_static_state) +
- nr_images * sizeof(struct draw_sampler_static_state));
+ sizeof(struct lp_sampler_static_state) +
+ nr_images * sizeof(struct lp_sampler_static_state));
}
static inline size_t
@@ -541,44 +312,44 @@ draw_tes_llvm_variant_key_size(unsigned nr_samplers,
{
return (sizeof(struct draw_tes_llvm_variant_key) +
(MAX2(nr_samplers, nr_sampler_views) - 1) *
- sizeof(struct draw_sampler_static_state) +
- nr_images * sizeof(struct draw_sampler_static_state));
+ sizeof(struct lp_sampler_static_state) +
+ nr_images * sizeof(struct lp_sampler_static_state));
}
-static inline struct draw_sampler_static_state *
+static inline struct lp_sampler_static_state *
draw_llvm_variant_key_samplers(struct draw_llvm_variant_key *key)
{
- return (struct draw_sampler_static_state *)
+ return (struct lp_sampler_static_state *)
&key->vertex_element[key->nr_vertex_elements];
}
-static inline struct draw_image_static_state *
+static inline struct lp_image_static_state *
draw_llvm_variant_key_images(struct draw_llvm_variant_key *key)
{
- struct draw_sampler_static_state *samplers = (struct draw_sampler_static_state *)
+ struct lp_sampler_static_state *samplers = (struct lp_sampler_static_state *)
(&key->vertex_element[key->nr_vertex_elements]);
- return (struct draw_image_static_state *)
+ return (struct lp_image_static_state *)
&samplers[MAX2(key->nr_samplers, key->nr_sampler_views)];
}
-static inline struct draw_image_static_state *
+static inline struct lp_image_static_state *
draw_gs_llvm_variant_key_images(struct draw_gs_llvm_variant_key *key)
{
- return (struct draw_image_static_state *)
+ return (struct lp_image_static_state *)
&key->samplers[MAX2(key->nr_samplers, key->nr_sampler_views)];
}
-static inline struct draw_image_static_state *
+static inline struct lp_image_static_state *
draw_tcs_llvm_variant_key_images(struct draw_tcs_llvm_variant_key *key)
{
- return (struct draw_image_static_state *)
+ return (struct lp_image_static_state *)
&key->samplers[MAX2(key->nr_samplers, key->nr_sampler_views)];
}
-static inline struct draw_image_static_state *
+static inline struct lp_image_static_state *
draw_tes_llvm_variant_key_images(struct draw_tes_llvm_variant_key *key)
{
- return (struct draw_image_static_state *)
+ return (struct lp_image_static_state *)
&key->samplers[MAX2(key->nr_samplers, key->nr_sampler_views)];
}
@@ -614,6 +385,9 @@ struct draw_llvm_variant
LLVMTypeRef context_type;
LLVMTypeRef context_ptr_type;
+ LLVMTypeRef resources_type;
+ LLVMTypeRef resources_ptr_type;
+
LLVMTypeRef buffer_type;
LLVMTypeRef buffer_ptr_type;
@@ -645,6 +419,9 @@ struct draw_gs_llvm_variant
LLVMTypeRef context_type;
LLVMTypeRef context_ptr_type;
+ LLVMTypeRef resources_type;
+ LLVMTypeRef resources_ptr_type;
+
LLVMTypeRef vertex_header_type;
LLVMTypeRef vertex_header_ptr_type;
@@ -671,8 +448,8 @@ struct draw_tcs_llvm_variant
struct gallivm_state *gallivm;
/* LLVM JIT builder types */
- LLVMTypeRef context_type;
- LLVMTypeRef context_ptr_type;
+ LLVMTypeRef resources_type;
+ LLVMTypeRef resources_ptr_type;
LLVMTypeRef input_array_type;
LLVMTypeRef output_array_type;
@@ -697,8 +474,8 @@ struct draw_tes_llvm_variant
struct gallivm_state *gallivm;
/* LLVM JIT builder types */
- LLVMTypeRef context_type;
- LLVMTypeRef context_ptr_type;
+ LLVMTypeRef resources_type;
+ LLVMTypeRef resources_ptr_type;
LLVMTypeRef vertex_header_ptr_type;
LLVMTypeRef input_array_type;
LLVMTypeRef patch_input_array_type;
@@ -762,12 +539,12 @@ struct draw_llvm {
struct draw_context *draw;
LLVMContextRef context;
- boolean context_owned;
+ bool context_owned;
- struct draw_jit_context jit_context;
+ struct draw_vs_jit_context vs_jit_context;
struct draw_gs_jit_context gs_jit_context;
- struct draw_tcs_jit_context tcs_jit_context;
- struct draw_tes_jit_context tes_jit_context;
+
+ struct lp_jit_resources jit_resources[DRAW_MAX_SHADER_STAGE];
struct draw_llvm_variant_list_item vs_variants_list;
int nr_variants;
@@ -870,25 +647,6 @@ draw_tes_llvm_make_variant_key(struct draw_llvm *llvm, char *store);
void
draw_tes_llvm_dump_variant_key(struct draw_tes_llvm_variant_key *key);
-struct lp_build_sampler_soa *
-draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state,
- unsigned nr_samplers);
-static inline void
-draw_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler)
-{
- FREE(sampler);
-}
-
-struct lp_build_image_soa *
-draw_llvm_image_soa_create(const struct draw_image_static_state *static_state,
- unsigned nr_images);
-
-static inline void
-draw_llvm_image_soa_destroy(struct lp_build_image_soa *image)
-{
- FREE(image);
-}
-
void
draw_llvm_set_sampler_state(struct draw_context *draw,
enum pipe_shader_type shader_stage);
@@ -916,4 +674,17 @@ draw_llvm_set_mapped_image(struct draw_context *draw,
uint32_t img_stride,
uint32_t num_samples,
uint32_t sample_stride);
+
+void
+draw_store_aos_array(struct gallivm_state *gallivm,
+ struct lp_type soa_type,
+ LLVMTypeRef io_type,
+ LLVMValueRef io_ptr,
+ LLVMValueRef *indices,
+ LLVMValueRef* aos,
+ int attrib,
+ LLVMValueRef clipmask,
+ bool need_edgeflag,
+ bool per_prim);
+
#endif
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_llvm_sample.c b/lib/mesa/src/gallium/auxiliary/draw/draw_llvm_sample.c
deleted file mode 100644
index 32cad59d6..000000000
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_llvm_sample.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2010 VMware, Inc.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * Texture sampling code generation
- * @author Jose Fonseca <jfonseca@vmware.com>
- */
-
-#include "pipe/p_defines.h"
-#include "pipe/p_shader_tokens.h"
-#include "gallivm/lp_bld_const.h"
-#include "gallivm/lp_bld_debug.h"
-#include "gallivm/lp_bld_type.h"
-#include "gallivm/lp_bld_sample.h"
-#include "gallivm/lp_bld_tgsi.h"
-
-
-#include "util/u_debug.h"
-#include "util/u_memory.h"
-#include "util/u_pointer.h"
-#include "util/u_string.h"
-
-#include "draw_llvm.h"
-
-
-/**
- * This provides the bridge between the sampler state store in
- * lp_jit_context and lp_jit_texture and the sampler code
- * generator. It provides the texture layout information required by
- * the texture sampler code generator in terms of the state stored in
- * lp_jit_context and lp_jit_texture in runtime.
- */
-struct draw_llvm_sampler_dynamic_state
-{
- struct lp_sampler_dynamic_state base;
-
- const struct draw_sampler_static_state *static_state;
-};
-
-
-/**
- * This is the bridge between our sampler and the TGSI translator.
- */
-struct draw_llvm_sampler_soa
-{
- struct lp_build_sampler_soa base;
-
- struct draw_llvm_sampler_dynamic_state dynamic_state;
-};
-
-
-/**
- * Fetch the specified member of the lp_jit_texture structure.
- * \param emit_load if TRUE, emit the LLVM load instruction to actually
- * fetch the field's value. Otherwise, just emit the
- * GEP code to address the field.
- *
- * @sa http://llvm.org/docs/GetElementPtr.html
- */
-static LLVMValueRef
-draw_llvm_texture_member(const struct lp_sampler_dynamic_state *base,
- struct gallivm_state *gallivm,
- LLVMValueRef context_ptr,
- unsigned texture_unit,
- unsigned member_index,
- const char *member_name,
- boolean emit_load)
-{
- LLVMBuilderRef builder = gallivm->builder;
- LLVMValueRef indices[4];
- LLVMValueRef ptr;
- LLVMValueRef res;
-
- debug_assert(texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
-
- /* context[0] */
- indices[0] = lp_build_const_int32(gallivm, 0);
- /* context[0].textures */
- indices[1] = lp_build_const_int32(gallivm, DRAW_JIT_CTX_TEXTURES);
- /* context[0].textures[unit] */
- indices[2] = lp_build_const_int32(gallivm, texture_unit);
- /* context[0].textures[unit].member */
- indices[3] = lp_build_const_int32(gallivm, member_index);
-
- ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), "");
-
- if (emit_load)
- res = LLVMBuildLoad(builder, ptr, "");
- else
- res = ptr;
-
- lp_build_name(res, "context.texture%u.%s", texture_unit, member_name);
-
- return res;
-}
-
-
-/**
- * Fetch the specified member of the lp_jit_sampler structure.
- * \param emit_load if TRUE, emit the LLVM load instruction to actually
- * fetch the field's value. Otherwise, just emit the
- * GEP code to address the field.
- *
- * @sa http://llvm.org/docs/GetElementPtr.html
- */
-static LLVMValueRef
-draw_llvm_sampler_member(const struct lp_sampler_dynamic_state *base,
- struct gallivm_state *gallivm,
- LLVMValueRef context_ptr,
- unsigned sampler_unit,
- unsigned member_index,
- const char *member_name,
- boolean emit_load)
-{
- LLVMBuilderRef builder = gallivm->builder;
- LLVMValueRef indices[4];
- LLVMValueRef ptr;
- LLVMValueRef res;
-
- debug_assert(sampler_unit < PIPE_MAX_SAMPLERS);
-
- /* context[0] */
- indices[0] = lp_build_const_int32(gallivm, 0);
- /* context[0].samplers */
- indices[1] = lp_build_const_int32(gallivm, DRAW_JIT_CTX_SAMPLERS);
- /* context[0].samplers[unit] */
- indices[2] = lp_build_const_int32(gallivm, sampler_unit);
- /* context[0].samplers[unit].member */
- indices[3] = lp_build_const_int32(gallivm, member_index);
-
- ptr = LLVMBuildGEP(builder, context_ptr, indices, Elements(indices), "");
-
- if (emit_load)
- res = LLVMBuildLoad(builder, ptr, "");
- else
- res = ptr;
-
- lp_build_name(res, "context.sampler%u.%s", sampler_unit, member_name);
-
- return res;
-}
-
-
-/**
- * Helper macro to instantiate the functions that generate the code to
- * fetch the members of lp_jit_texture to fulfill the sampler code
- * generator requests.
- *
- * This complexity is the price we have to pay to keep the texture
- * sampler code generator a reusable module without dependencies to
- * llvmpipe internals.
- */
-#define DRAW_LLVM_TEXTURE_MEMBER(_name, _index, _emit_load) \
- static LLVMValueRef \
- draw_llvm_texture_##_name( const struct lp_sampler_dynamic_state *base, \
- struct gallivm_state *gallivm, \
- LLVMValueRef context_ptr, \
- unsigned texture_unit) \
- { \
- return draw_llvm_texture_member(base, gallivm, context_ptr, \
- texture_unit, _index, #_name, _emit_load ); \
- }
-
-
-DRAW_LLVM_TEXTURE_MEMBER(width, DRAW_JIT_TEXTURE_WIDTH, TRUE)
-DRAW_LLVM_TEXTURE_MEMBER(height, DRAW_JIT_TEXTURE_HEIGHT, TRUE)
-DRAW_LLVM_TEXTURE_MEMBER(depth, DRAW_JIT_TEXTURE_DEPTH, TRUE)
-DRAW_LLVM_TEXTURE_MEMBER(first_level,DRAW_JIT_TEXTURE_FIRST_LEVEL, TRUE)
-DRAW_LLVM_TEXTURE_MEMBER(last_level, DRAW_JIT_TEXTURE_LAST_LEVEL, TRUE)
-DRAW_LLVM_TEXTURE_MEMBER(base_ptr, DRAW_JIT_TEXTURE_BASE, TRUE)
-DRAW_LLVM_TEXTURE_MEMBER(row_stride, DRAW_JIT_TEXTURE_ROW_STRIDE, FALSE)
-DRAW_LLVM_TEXTURE_MEMBER(img_stride, DRAW_JIT_TEXTURE_IMG_STRIDE, FALSE)
-DRAW_LLVM_TEXTURE_MEMBER(mip_offsets, DRAW_JIT_TEXTURE_MIP_OFFSETS, FALSE)
-
-
-#define DRAW_LLVM_SAMPLER_MEMBER(_name, _index, _emit_load) \
- static LLVMValueRef \
- draw_llvm_sampler_##_name( const struct lp_sampler_dynamic_state *base, \
- struct gallivm_state *gallivm, \
- LLVMValueRef context_ptr, \
- unsigned sampler_unit) \
- { \
- return draw_llvm_sampler_member(base, gallivm, context_ptr, \
- sampler_unit, _index, #_name, _emit_load ); \
- }
-
-
-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)
-
-
-static void
-draw_llvm_sampler_soa_destroy(struct lp_build_sampler_soa *sampler)
-{
- FREE(sampler);
-}
-
-
-/**
- * Fetch filtered values from texture.
- * The 'texel' parameter returns four vectors corresponding to R, G, B, A.
- */
-static void
-draw_llvm_sampler_soa_emit_fetch_texel(const struct lp_build_sampler_soa *base,
- struct gallivm_state *gallivm,
- const struct lp_sampler_params *params)
-{
- struct draw_llvm_sampler_soa *sampler = (struct draw_llvm_sampler_soa *)base;
- unsigned texture_index = params->texture_index;
- unsigned sampler_index = params->sampler_index;
-
- assert(texture_index < PIPE_MAX_SHADER_SAMPLER_VIEWS);
- assert(sampler_index < PIPE_MAX_SAMPLERS);
-
- lp_build_sample_soa(&sampler->dynamic_state.static_state[texture_index].texture_state,
- &sampler->dynamic_state.static_state[sampler_index].sampler_state,
- &sampler->dynamic_state.base,
- gallivm, params);
-}
-
-
-/**
- * Fetch the texture size.
- */
-static void
-draw_llvm_sampler_soa_emit_size_query(const struct lp_build_sampler_soa *base,
- struct gallivm_state *gallivm,
- struct lp_type type,
- unsigned texture_unit,
- unsigned target,
- LLVMValueRef context_ptr,
- boolean is_sviewinfo,
- enum lp_sampler_lod_property lod_property,
- LLVMValueRef explicit_lod, /* optional */
- LLVMValueRef *sizes_out)
-{
- struct draw_llvm_sampler_soa *sampler = (struct draw_llvm_sampler_soa *)base;
-
- assert(texture_unit < PIPE_MAX_SHADER_SAMPLER_VIEWS);
-
- lp_build_size_query_soa(gallivm,
- &sampler->dynamic_state.static_state[texture_unit].texture_state,
- &sampler->dynamic_state.base,
- type,
- texture_unit,
- target,
- context_ptr,
- is_sviewinfo,
- lod_property,
- explicit_lod,
- sizes_out);
-}
-
-struct lp_build_sampler_soa *
-draw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state)
-{
- struct draw_llvm_sampler_soa *sampler;
-
- sampler = CALLOC_STRUCT(draw_llvm_sampler_soa);
- if(!sampler)
- return NULL;
-
- sampler->base.destroy = draw_llvm_sampler_soa_destroy;
- sampler->base.emit_tex_sample = draw_llvm_sampler_soa_emit_fetch_texel;
- sampler->base.emit_size_query = draw_llvm_sampler_soa_emit_size_query;
- sampler->dynamic_state.base.width = draw_llvm_texture_width;
- sampler->dynamic_state.base.height = draw_llvm_texture_height;
- sampler->dynamic_state.base.depth = draw_llvm_texture_depth;
- sampler->dynamic_state.base.first_level = draw_llvm_texture_first_level;
- sampler->dynamic_state.base.last_level = draw_llvm_texture_last_level;
- sampler->dynamic_state.base.row_stride = draw_llvm_texture_row_stride;
- sampler->dynamic_state.base.img_stride = draw_llvm_texture_img_stride;
- sampler->dynamic_state.base.base_ptr = draw_llvm_texture_base_ptr;
- sampler->dynamic_state.base.mip_offsets = draw_llvm_texture_mip_offsets;
- sampler->dynamic_state.base.min_lod = draw_llvm_sampler_min_lod;
- 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.static_state = static_state;
-
- return &sampler->base;
-}
-
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_aaline.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_aaline.c
index d2bc475b2..9720faa20 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_aaline.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_aaline.c
@@ -77,9 +77,9 @@ struct aaline_stage
float half_line_width;
/** For AA lines, this is the vertex attrib slot for new generic */
- uint coord_slot;
+ unsigned coord_slot;
/** position, not necessarily output zero */
- uint pos_slot;
+ unsigned pos_slot;
/*
@@ -135,7 +135,7 @@ aa_transform_decl(struct tgsi_transform_context *ctx,
}
}
else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
- uint i;
+ unsigned i;
for (i = decl->Range.First;
i <= decl->Range.Last; i++) {
/*
@@ -285,7 +285,7 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
struct tgsi_full_instruction *inst)
{
struct aa_transform_context *aactx = (struct aa_transform_context *) ctx;
- uint i;
+ unsigned i;
/*
* Look for writes to result.color and replace with colorTemp reg.
@@ -307,14 +307,14 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
* Generate the frag shader we'll use for drawing AA lines.
* This will be the user's shader plus some arithmetic instructions.
*/
-static boolean
+static bool
generate_aaline_fs(struct aaline_stage *aaline)
{
struct pipe_context *pipe = aaline->stage.draw->pipe;
const struct pipe_shader_state *orig_fs = &aaline->fs->state;
struct pipe_shader_state aaline_fs;
struct aa_transform_context transform;
- const uint newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
+ const unsigned newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
aaline_fs = *orig_fs; /* copy to init */
@@ -349,7 +349,7 @@ generate_aaline_fs(struct aaline_stage *aaline)
return aaline->fs->aaline_fs != NULL;
}
-static boolean
+static bool
generate_aaline_fs_nir(struct aaline_stage *aaline)
{
struct pipe_context *pipe = aaline->stage.draw->pipe;
@@ -359,21 +359,21 @@ generate_aaline_fs_nir(struct aaline_stage *aaline)
aaline_fs = *orig_fs; /* copy to init */
aaline_fs.ir.nir = nir_shader_clone(NULL, orig_fs->ir.nir);
if (!aaline_fs.ir.nir)
- return FALSE;
+ return false;
nir_lower_aaline_fs(aaline_fs.ir.nir, &aaline->fs->generic_attrib, NULL, NULL);
aaline->fs->aaline_fs = aaline->driver_create_fs_state(pipe, &aaline_fs);
if (aaline->fs->aaline_fs == NULL)
- return FALSE;
+ return false;
- return TRUE;
+ return true;
}
/**
* When we're about to draw our first AA line in a batch, this function is
* called to tell the driver to bind our modified fragment shader.
*/
-static boolean
+static bool
bind_aaline_fragment_shader(struct aaline_stage *aaline)
{
struct draw_context *draw = aaline->stage.draw;
@@ -382,17 +382,17 @@ bind_aaline_fragment_shader(struct aaline_stage *aaline)
if (!aaline->fs->aaline_fs) {
if (aaline->fs->state.type == PIPE_SHADER_IR_NIR) {
if (!generate_aaline_fs_nir(aaline))
- return FALSE;
+ return false;
} else
if (!generate_aaline_fs(aaline))
- return FALSE;
+ return false;
}
- draw->suspend_flushing = TRUE;
+ draw->suspend_flushing = true;
aaline->driver_bind_fs_state(pipe, aaline->fs->aaline_fs);
- draw->suspend_flushing = FALSE;
+ draw->suspend_flushing = false;
- return TRUE;
+ return true;
}
@@ -415,8 +415,8 @@ aaline_line(struct draw_stage *stage, struct prim_header *header)
const float half_width = aaline->half_line_width;
struct prim_header tri;
struct vertex_header *v[8];
- uint coordPos = aaline->coord_slot;
- uint posPos = aaline->pos_slot;
+ unsigned coordPos = aaline->coord_slot;
+ unsigned posPos = aaline->pos_slot;
float *pos, *tex;
float dx = header->v[1]->data[posPos][0] - header->v[0]->data[posPos][0];
float dy = header->v[1]->data[posPos][1] - header->v[0]->data[posPos][1];
@@ -424,7 +424,7 @@ aaline_line(struct draw_stage *stage, struct prim_header *header)
float c_a = dx / length, s_a = dy / length;
float half_length = 0.5 * length;
float t_l, t_w;
- uint i;
+ unsigned i;
half_length = half_length + 0.5f;
@@ -527,13 +527,13 @@ aaline_first_line(struct draw_stage *stage, struct prim_header *header)
draw_aaline_prepare_outputs(draw, draw->pipeline.aaline);
- draw->suspend_flushing = TRUE;
+ draw->suspend_flushing = true;
/* Disable triangle culling, stippling, unfilled mode etc. */
r = draw_get_rasterizer_no_cull(draw, rast);
pipe->bind_rasterizer_state(pipe, r);
- draw->suspend_flushing = FALSE;
+ draw->suspend_flushing = false;
/* now really draw first line */
stage->line = aaline_line;
@@ -552,7 +552,7 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
stage->next->flush(stage->next, flags);
/* restore original frag shader */
- draw->suspend_flushing = TRUE;
+ draw->suspend_flushing = true;
aaline->driver_bind_fs_state(pipe, aaline->fs ? aaline->fs->driver_fs : NULL);
/* restore original rasterizer state */
@@ -560,7 +560,7 @@ aaline_flush(struct draw_stage *stage, unsigned flags)
pipe->bind_rasterizer_state(pipe, draw->rast_handle);
}
- draw->suspend_flushing = FALSE;
+ draw->suspend_flushing = false;
draw_remove_extra_vertex_attribs(draw);
}
@@ -731,7 +731,7 @@ draw_aaline_prepare_outputs(struct draw_context *draw,
* into the draw module's pipeline. This will not be used if the
* hardware has native support for AA lines.
*/
-boolean
+bool
draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
{
struct aaline_stage *aaline;
@@ -743,7 +743,7 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
*/
aaline = draw_aaline_stage(draw);
if (!aaline)
- return FALSE;
+ return false;
/* save original driver functions */
aaline->driver_create_fs_state = pipe->create_fs_state;
@@ -759,5 +759,5 @@ draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe)
*/
draw->pipeline.aaline = &aaline->stage;
- return TRUE;
+ return true;
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_aapoint.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
index b1b66f653..14fbb8420 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_aapoint.c
@@ -94,10 +94,10 @@ struct aapoint_stage
int psize_slot;
/** this is the vertex attrib slot for the new texcoords */
- uint tex_slot;
+ unsigned tex_slot;
/** vertex attrib slot containing position */
- uint pos_slot;
+ unsigned pos_slot;
/** Type of Boolean variables on this hardware. */
nir_alu_type bool_type;
@@ -122,7 +122,7 @@ struct aapoint_stage
*/
struct aa_transform_context {
struct tgsi_transform_context base;
- uint tempsUsed; /**< bitmask */
+ uint32_t tempsUsed; /**< bitmask */
int colorOutput; /**< which output is the primary color */
int maxInput, maxGeneric; /**< max input index found */
int tmp0, colorTemp; /**< temp registers */
@@ -153,10 +153,10 @@ aa_transform_decl(struct tgsi_transform_context *ctx,
}
}
else if (decl->Declaration.File == TGSI_FILE_TEMPORARY) {
- uint i;
+ unsigned i;
for (i = decl->Range.First;
i <= decl->Range.Last; i++) {
- aactx->tempsUsed |= (1 << i);
+ aactx->tempsUsed |= 1u << i;
}
}
@@ -176,7 +176,7 @@ aa_transform_prolog(struct tgsi_transform_context *ctx)
struct tgsi_full_instruction newInst;
const int texInput = aactx->maxInput + 1;
int tmp0;
- uint i;
+ unsigned i;
/* find two free temp regs */
for (i = 0; i < 32; i++) {
@@ -246,7 +246,7 @@ aa_transform_prolog(struct tgsi_transform_context *ctx)
/* KILL_IF -tmp0.yyyy; # if -tmp0.y < 0, KILL */
tgsi_transform_kill_inst(ctx, TGSI_FILE_TEMPORARY, tmp0,
- TGSI_SWIZZLE_Y, TRUE);
+ TGSI_SWIZZLE_Y, true);
/* compute coverage factor = (1-d)/(1-k) */
@@ -359,13 +359,13 @@ aa_transform_inst(struct tgsi_transform_context *ctx,
* Generate the frag shader we'll use for drawing AA points.
* This will be the user's shader plus some texture/modulate instructions.
*/
-static boolean
+static bool
generate_aapoint_fs(struct aapoint_stage *aapoint)
{
const struct pipe_shader_state *orig_fs = &aapoint->fs->state;
struct pipe_shader_state aapoint_fs;
struct aa_transform_context transform;
- const uint newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
+ const unsigned newLen = tgsi_num_tokens(orig_fs->tokens) + NUM_NEW_TOKENS;
struct pipe_context *pipe = aapoint->stage.draw->pipe;
aapoint_fs = *orig_fs; /* copy to init */
@@ -401,15 +401,15 @@ generate_aapoint_fs(struct aapoint_stage *aapoint)
aapoint->fs->generic_attrib = transform.maxGeneric + 1;
FREE((void *)aapoint_fs.tokens);
- return TRUE;
+ return true;
fail:
FREE((void *)aapoint_fs.tokens);
- return FALSE;
+ return false;
}
-static boolean
+static bool
generate_aapoint_fs_nir(struct aapoint_stage *aapoint)
{
struct pipe_context *pipe = aapoint->stage.draw->pipe;
@@ -419,17 +419,17 @@ generate_aapoint_fs_nir(struct aapoint_stage *aapoint)
aapoint_fs = *orig_fs; /* copy to init */
aapoint_fs.ir.nir = nir_shader_clone(NULL, orig_fs->ir.nir);
if (!aapoint_fs.ir.nir)
- return FALSE;
+ return false;
nir_lower_aapoint_fs(aapoint_fs.ir.nir, &aapoint->fs->generic_attrib, aapoint->bool_type);
aapoint->fs->aapoint_fs = aapoint->driver_create_fs_state(pipe, &aapoint_fs);
if (aapoint->fs->aapoint_fs == NULL)
goto fail;
- return TRUE;
+ return true;
fail:
- return FALSE;
+ return false;
}
@@ -437,7 +437,7 @@ fail:
* When we're about to draw our first AA point in a batch, this function is
* called to tell the driver to bind our modified fragment shader.
*/
-static boolean
+static bool
bind_aapoint_fragment_shader(struct aapoint_stage *aapoint)
{
struct draw_context *draw = aapoint->stage.draw;
@@ -446,16 +446,16 @@ bind_aapoint_fragment_shader(struct aapoint_stage *aapoint)
if (!aapoint->fs->aapoint_fs) {
if (aapoint->fs->state.type == PIPE_SHADER_IR_NIR) {
if (!generate_aapoint_fs_nir(aapoint))
- return FALSE;
+ return false;
} else if (!generate_aapoint_fs(aapoint))
- return FALSE;
+ return false;
}
- draw->suspend_flushing = TRUE;
+ draw->suspend_flushing = true;
aapoint->driver_bind_fs_state(pipe, aapoint->fs->aapoint_fs);
- draw->suspend_flushing = FALSE;
+ draw->suspend_flushing = false;
- return TRUE;
+ return true;
}
@@ -475,8 +475,8 @@ aapoint_point(struct draw_stage *stage, struct prim_header *header)
const struct aapoint_stage *aapoint = aapoint_stage(stage);
struct prim_header tri;
struct vertex_header *v[4];
- const uint tex_slot = aapoint->tex_slot;
- const uint pos_slot = aapoint->pos_slot;
+ const unsigned tex_slot = aapoint->tex_slot;
+ const unsigned pos_slot = aapoint->pos_slot;
float radius, *pos, *tex;
float k;
@@ -590,13 +590,13 @@ aapoint_first_point(struct draw_stage *stage, struct prim_header *header)
draw_aapoint_prepare_outputs(draw, draw->pipeline.aapoint);
- draw->suspend_flushing = TRUE;
+ draw->suspend_flushing = true;
/* Disable triangle culling, stippling, unfilled mode etc. */
r = draw_get_rasterizer_no_cull(draw, rast);
pipe->bind_rasterizer_state(pipe, r);
- draw->suspend_flushing = FALSE;
+ draw->suspend_flushing = false;
/* now really draw first point */
stage->point = aapoint_point;
@@ -615,7 +615,7 @@ aapoint_flush(struct draw_stage *stage, unsigned flags)
stage->next->flush(stage->next, flags);
/* restore original frag shader */
- draw->suspend_flushing = TRUE;
+ draw->suspend_flushing = true;
aapoint->driver_bind_fs_state(pipe, aapoint->fs ? aapoint->fs->driver_fs : NULL);
/* restore original rasterizer state */
@@ -623,7 +623,7 @@ aapoint_flush(struct draw_stage *stage, unsigned flags)
pipe->bind_rasterizer_state(pipe, draw->rast_handle);
}
- draw->suspend_flushing = FALSE;
+ draw->suspend_flushing = false;
draw_remove_extra_vertex_attribs(draw);
}
@@ -795,7 +795,7 @@ aapoint_delete_fs_state(struct pipe_context *pipe, void *fs)
* into the draw module's pipeline. This will not be used if the
* hardware has native support for AA points.
*/
-boolean
+bool
draw_install_aapoint_stage(struct draw_context *draw,
struct pipe_context *pipe,
nir_alu_type bool_type)
@@ -809,7 +809,7 @@ draw_install_aapoint_stage(struct draw_context *draw,
*/
aapoint = draw_aapoint_stage(draw, bool_type);
if (!aapoint)
- return FALSE;
+ return false;
/* save original driver functions */
aapoint->driver_create_fs_state = pipe->create_fs_state;
@@ -823,5 +823,5 @@ draw_install_aapoint_stage(struct draw_context *draw,
draw->pipeline.aapoint = &aapoint->stage;
- return TRUE;
+ return true;
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_clip.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_clip.c
index b6b7b4f06..7a47a7a5f 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_clip.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_clip.c
@@ -54,17 +54,17 @@ struct clip_stage {
struct draw_stage stage; /**< base class */
unsigned pos_attr;
- boolean have_clipdist;
+ bool have_clipdist;
int cv_attr;
/* List of the attributes to be constant interpolated. */
- uint num_const_attribs;
+ unsigned num_const_attribs;
uint8_t const_attribs[PIPE_MAX_SHADER_OUTPUTS];
/* List of the attributes to be linear interpolated. */
- uint num_linear_attribs;
+ unsigned num_linear_attribs;
uint8_t linear_attribs[PIPE_MAX_SHADER_OUTPUTS];
/* List of the attributes to be perspective interpolated. */
- uint num_perspect_attribs;
+ unsigned num_perspect_attribs;
uint8_t perspect_attribs[PIPE_MAX_SHADER_OUTPUTS];
float (*plane)[4];
@@ -123,7 +123,7 @@ copy_flat(struct draw_stage *stage,
{
const struct clip_stage *clipper = clip_stage(stage);
for (unsigned i = 0; i < clipper->num_const_attribs; i++) {
- const uint attr = clipper->const_attribs[i];
+ const unsigned attr = clipper->const_attribs[i];
COPY_4FV(dst->data[attr], src->data[attr]);
}
}
@@ -217,12 +217,12 @@ interp(const struct clip_stage *clip,
static void
emit_poly(struct draw_stage *stage,
struct vertex_header **inlist,
- const boolean *edgeflags,
+ const bool *edgeflags,
unsigned n,
const struct prim_header *origPrim)
{
const struct clip_stage *clipper = clip_stage(stage);
- ushort edge_first, edge_middle, edge_last;
+ uint16_t edge_first, edge_middle, edge_last;
if (stage->draw->rasterizer->flatshade_first) {
edge_first = DRAW_PIPE_EDGE_FLAG_0;
@@ -353,10 +353,10 @@ do_clip_tri(struct draw_stage *stage,
struct vertex_header *prov_vertex;
unsigned tmpnr = 0;
unsigned n = 3;
- boolean aEdges[MAX_CLIPPED_VERTICES];
- boolean bEdges[MAX_CLIPPED_VERTICES];
- boolean *inEdges = aEdges;
- boolean *outEdges = bEdges;
+ bool aEdges[MAX_CLIPPED_VERTICES];
+ bool bEdges[MAX_CLIPPED_VERTICES];
+ bool *inEdges = aEdges;
+ bool *outEdges = bEdges;
int viewport_index = 0;
inlist[0] = header->v[0];
@@ -410,9 +410,9 @@ do_clip_tri(struct draw_stage *stage,
while (clipmask && n >= 3) {
const unsigned plane_idx = ffs(clipmask)-1;
- const boolean is_user_clip_plane = plane_idx >= 6;
+ const bool is_user_clip_plane = plane_idx >= 6;
struct vertex_header *vert_prev = inlist[0];
- boolean *edge_prev = &inEdges[0];
+ bool *edge_prev = &inEdges[0];
float dp_prev;
unsigned outcount = 0;
@@ -430,8 +430,8 @@ do_clip_tri(struct draw_stage *stage,
for (unsigned i = 1; i <= n; i++) {
struct vertex_header *vert = inlist[i];
- boolean *edge = &inEdges[i];
- boolean different_sign;
+ bool *edge = &inEdges[i];
+ bool different_sign;
float dp = getclipdist(clipper, vert, plane_idx);
@@ -451,7 +451,7 @@ do_clip_tri(struct draw_stage *stage,
if (different_sign) {
struct vertex_header *new_vert;
- boolean *new_edge;
+ bool *new_edge;
assert(tmpnr < MAX_CLIPPED_VERTICES + 1);
if (tmpnr >= MAX_CLIPPED_VERTICES + 1)
@@ -484,13 +484,13 @@ do_clip_tri(struct draw_stage *stage,
*/
if (is_user_clip_plane) {
/* we want to see an edge along the clip plane */
- *new_edge = TRUE;
- new_vert->edgeflag = TRUE;
+ *new_edge = true;
+ new_vert->edgeflag = true;
}
else {
/* we don't want to see an edge along the frustum clip plane */
*new_edge = *edge_prev;
- new_vert->edgeflag = FALSE;
+ new_vert->edgeflag = false;
}
}
else {
@@ -524,7 +524,7 @@ do_clip_tri(struct draw_stage *stage,
n = outcount;
}
{
- boolean *tmp = inEdges;
+ bool *tmp = inEdges;
inEdges = outEdges;
outEdges = tmp;
}
@@ -688,7 +688,7 @@ clip_point_guard_xy(struct draw_stage *stage, struct prim_header *header)
static void
clip_first_point(struct draw_stage *stage, struct prim_header *header)
{
- stage->point = stage->draw->guard_band_points_xy ? clip_point_guard_xy : clip_point;
+ stage->point = stage->draw->guard_band_points_lines_xy ? clip_point_guard_xy : clip_point;
stage->point(stage, header);
}
@@ -710,6 +710,40 @@ clip_line(struct draw_stage *stage, struct prim_header *header)
/* else, totally clipped */
}
+static void
+clip_line_guard_xy(struct draw_stage *stage, struct prim_header *header)
+{
+ unsigned clipmask = (header->v[0]->clipmask |
+ header->v[1]->clipmask);
+
+ if ((clipmask & 0xffffffff) == 0) {
+ stage->next->line(stage->next, header);
+ }
+ else if ((clipmask & 0xfffffff0) == 0) {
+ while (clipmask) {
+ const unsigned plane_idx = ffs(clipmask)-1;
+ clipmask &= ~(1 << plane_idx); /* turn off this plane's bit */
+ /* TODO: this should really do proper guardband clipping,
+ * currently just throw out infs/nans.
+ * Also note that vertices with negative w values MUST be tossed
+ * out (not sure if proper guardband clipping would do this
+ * automatically). These would usually be captured by depth clip
+ * too but this can be disabled.
+ */
+ if ((header->v[0]->clip_pos[3] <= 0.0f &&
+ header->v[1]->clip_pos[3] <= 0.0f) ||
+ util_is_nan(header->v[0]->clip_pos[0]) ||
+ util_is_nan(header->v[0]->clip_pos[1]) ||
+ util_is_nan(header->v[1]->clip_pos[0]) ||
+ util_is_nan(header->v[1]->clip_pos[1]))
+ return;
+ }
+ stage->next->line(stage->next, header);
+ } else if ((header->v[0]->clipmask &
+ header->v[1]->clipmask) == 0) {
+ do_clip_line(stage, header, clipmask & 0xfffffff0);
+ }
+}
static void
clip_tri(struct draw_stage *stage, struct prim_header *header)
@@ -733,7 +767,7 @@ clip_tri(struct draw_stage *stage, struct prim_header *header)
static enum tgsi_interpolate_mode
find_interp(const struct draw_fragment_shader *fs,
enum tgsi_interpolate_mode *indexed_interp,
- uint semantic_name, uint semantic_index)
+ enum tgsi_semantic semantic_name, unsigned semantic_index)
{
enum tgsi_interpolate_mode interp;
@@ -753,7 +787,7 @@ find_interp(const struct draw_fragment_shader *fs,
* This probably only matters for layer, vpindex, culldist, maybe
* front_face.
*/
- uint j;
+ unsigned j;
if (semantic_name == TGSI_SEMANTIC_LAYER ||
semantic_name == TGSI_SEMANTIC_VIEWPORT_INDEX) {
interp = TGSI_INTERPOLATE_CONSTANT;
@@ -894,7 +928,6 @@ clip_init_state(struct draw_stage *stage)
}
stage->tri = clip_tri;
- stage->line = clip_line;
}
@@ -912,6 +945,7 @@ clip_first_line(struct draw_stage *stage,
struct prim_header *header)
{
clip_init_state(stage);
+ stage->line = stage->draw->guard_band_points_lines_xy ? clip_line_guard_xy : clip_line;
stage->line(stage, header);
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_flatshade.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
index 7ad7c79b7..378f169e0 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_flatshade.c
@@ -42,8 +42,8 @@ struct flat_stage
{
struct draw_stage stage;
- uint num_flat_attribs;
- uint flat_attribs[PIPE_MAX_SHADER_OUTPUTS]; /* flatshaded attribs */
+ unsigned num_flat_attribs;
+ unsigned flat_attribs[PIPE_MAX_SHADER_OUTPUTS]; /* flatshaded attribs */
};
@@ -62,7 +62,7 @@ copy_flats(struct draw_stage *stage,
{
const struct flat_stage *flat = flat_stage(stage);
for (unsigned i = 0; i < flat->num_flat_attribs; i++) {
- const uint attr = flat->flat_attribs[i];
+ const unsigned attr = flat->flat_attribs[i];
COPY_4FV(dst->data[attr], src->data[attr]);
}
}
@@ -77,7 +77,7 @@ copy_flats2(struct draw_stage *stage,
{
const struct flat_stage *flat = flat_stage(stage);
for (unsigned i = 0; i < flat->num_flat_attribs; i++) {
- const uint attr = flat->flat_attribs[i];
+ const unsigned attr = flat->flat_attribs[i];
COPY_4FV(dst0->data[attr], src->data[attr]);
COPY_4FV(dst1->data[attr], src->data[attr]);
}
@@ -168,7 +168,7 @@ flatshade_line_1(struct draw_stage *stage,
static int
find_interp(const struct draw_fragment_shader *fs, int *indexed_interp,
- uint semantic_name, uint semantic_index)
+ enum tgsi_semantic semantic_name, unsigned semantic_index)
{
int interp;
/* If it's gl_{Front,Back}{,Secondary}Color, pick up the mode
@@ -203,7 +203,7 @@ flatshade_init_state(struct draw_stage *stage)
const struct draw_context *draw = stage->draw;
const struct draw_fragment_shader *fs = draw->fs.fragment_shader;
const struct tgsi_shader_info *info = draw_get_shader_info(draw);
- uint i, j;
+ unsigned i, j;
/* Find which vertex shader outputs need constant interpolation, make a list */
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_stipple.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_stipple.c
index dd1fc8dd7..b379a3fc5 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_stipple.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_stipple.c
@@ -48,8 +48,8 @@
struct stipple_stage {
struct draw_stage stage;
unsigned counter;
- ushort pattern;
- ushort factor;
+ uint16_t pattern;
+ uint16_t factor;
bool rectangular;
};
@@ -73,13 +73,13 @@ screen_interp(struct draw_context *draw,
const struct vertex_header *v0,
const struct vertex_header *v1)
{
- uint attr;
- uint num_outputs = draw_current_shader_outputs(draw);
+ unsigned attr;
+ unsigned num_outputs = draw_current_shader_outputs(draw);
for (attr = 0; attr < num_outputs; attr++) {
const float *val0 = v0->data[attr];
const float *val1 = v1->data[attr];
float *newv = dst->data[attr];
- uint i;
+ unsigned i;
for (i = 0; i < 4; i++) {
newv[i] = val0[i] + t * (val1[i] - val0[i]);
}
@@ -110,7 +110,7 @@ emit_segment(struct draw_stage *stage, struct prim_header *header,
static inline bool
-stipple_test(unsigned counter, ushort pattern, ushort factor)
+stipple_test(unsigned counter, uint16_t pattern, uint16_t factor)
{
unsigned b = (counter / factor) & 0xf;
return !!((1 << b) & pattern);
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_user_cull.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_user_cull.c
index 09b3a6544..0a1289edf 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_user_cull.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_user_cull.c
@@ -40,7 +40,7 @@ struct user_cull_stage {
};
-static inline boolean
+static inline bool
cull_distance_is_out(float dist)
{
return (dist < 0.0f) || util_is_inf_or_nan(dist);
@@ -70,7 +70,7 @@ user_cull_point(struct draw_stage *stage,
draw_current_shader_ccdistance_output(stage->draw, cull_idx);
unsigned idx = (num_written_clipdistances + i) % 4;
float cull1 = header->v[0]->data[out_idx][idx];
- boolean vert1_out = cull_distance_is_out(cull1);
+ bool vert1_out = cull_distance_is_out(cull1);
if (vert1_out)
return;
}
@@ -102,8 +102,8 @@ user_cull_line(struct draw_stage *stage,
unsigned idx = (num_written_clipdistances + i) % 4;
float cull1 = header->v[0]->data[out_idx][idx];
float cull2 = header->v[1]->data[out_idx][idx];
- boolean vert1_out = cull_distance_is_out(cull1);
- boolean vert2_out = cull_distance_is_out(cull2);
+ bool vert1_out = cull_distance_is_out(cull1);
+ bool vert2_out = cull_distance_is_out(cull2);
if (vert1_out && vert2_out)
return;
}
@@ -137,9 +137,9 @@ user_cull_tri(struct draw_stage *stage,
float cull1 = header->v[0]->data[out_idx][idx];
float cull2 = header->v[1]->data[out_idx][idx];
float cull3 = header->v[2]->data[out_idx][idx];
- boolean vert1_out = cull_distance_is_out(cull1);
- boolean vert2_out = cull_distance_is_out(cull2);
- boolean vert3_out = cull_distance_is_out(cull3);
+ bool vert1_out = cull_distance_is_out(cull1);
+ bool vert2_out = cull_distance_is_out(cull2);
+ bool vert3_out = cull_distance_is_out(cull3);
if (vert1_out && vert2_out && vert3_out) {
return;
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_validate.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_validate.c
index e78bacd95..d53f27ca3 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_validate.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_validate.c
@@ -46,10 +46,10 @@
*
* This can be overridden by the driver.
*/
-boolean
+bool
draw_need_pipeline(const struct draw_context *draw,
const struct pipe_rasterizer_state *rasterizer,
- enum pipe_prim_type prim)
+ enum mesa_prim prim)
{
unsigned reduced_prim = u_reduced_prim(prim);
@@ -63,63 +63,63 @@ draw_need_pipeline(const struct draw_context *draw,
* and triggering the pipeline, because we have to trigger the
* pipeline *anyway* if unfilled mode is active.
*/
- if (reduced_prim == PIPE_PRIM_LINES) {
+ if (reduced_prim == MESA_PRIM_LINES) {
/* line stipple */
if (rasterizer->line_stipple_enable && draw->pipeline.line_stipple)
- return TRUE;
+ return true;
/* wide lines */
if (roundf(rasterizer->line_width) > draw->pipeline.wide_line_threshold)
- return TRUE;
+ return true;
/* AA lines */
if ((!rasterizer->multisample && rasterizer->line_smooth) && draw->pipeline.aaline)
- return TRUE;
+ return true;
if (draw_current_shader_num_written_culldistances(draw))
- return TRUE;
- } else if (reduced_prim == PIPE_PRIM_POINTS) {
+ return true;
+ } else if (reduced_prim == MESA_PRIM_POINTS) {
/* large points */
if (rasterizer->point_size > draw->pipeline.wide_point_threshold)
- return TRUE;
+ return true;
/* sprite points */
if (rasterizer->point_quad_rasterization
&& draw->pipeline.wide_point_sprites)
- return TRUE;
+ return true;
/* AA points */
if ((!rasterizer->multisample && rasterizer->point_smooth) && draw->pipeline.aapoint)
- return TRUE;
+ return true;
/* point sprites */
if (rasterizer->sprite_coord_enable && draw->pipeline.point_sprite)
- return TRUE;
+ return true;
if (draw_current_shader_num_written_culldistances(draw))
- return TRUE;
- } else if (reduced_prim == PIPE_PRIM_TRIANGLES) {
+ return true;
+ } else if (reduced_prim == MESA_PRIM_TRIANGLES) {
/* polygon stipple */
if (rasterizer->poly_stipple_enable && draw->pipeline.pstipple)
- return TRUE;
+ return true;
/* unfilled polygons */
if (rasterizer->fill_front != PIPE_POLYGON_MODE_FILL ||
rasterizer->fill_back != PIPE_POLYGON_MODE_FILL)
- return TRUE;
+ return true;
/* polygon offset */
if (rasterizer->offset_point ||
rasterizer->offset_line ||
rasterizer->offset_tri)
- return TRUE;
+ return true;
/* two-side lighting */
if (rasterizer->light_twoside)
- return TRUE;
+ return true;
if (draw_current_shader_num_written_culldistances(draw))
- return TRUE;
+ return true;
}
/* polygon cull - this is difficult - hardware can cull just fine
@@ -131,7 +131,7 @@ draw_need_pipeline(const struct draw_context *draw,
return TRUE;
*/
- return FALSE;
+ return false;
}
@@ -144,9 +144,9 @@ validate_pipeline(struct draw_stage *stage)
{
struct draw_context *draw = stage->draw;
struct draw_stage *next = draw->pipeline.rasterize;
- boolean need_det = FALSE;
- boolean precalc_flat = FALSE;
- boolean wide_lines, wide_points;
+ bool need_det = false;
+ bool precalc_flat = false;
+ bool wide_lines, wide_points;
const struct pipe_rasterizer_state *rast = draw->rasterizer;
/* Set the validate's next stage to the rasterize stage, so that it
@@ -161,15 +161,15 @@ validate_pipeline(struct draw_stage *stage)
/* drawing large/sprite points (but not AA points)? */
if (rast->sprite_coord_enable && draw->pipeline.point_sprite)
- wide_points = TRUE;
+ wide_points = true;
else if ((!rast->multisample && rast->point_smooth) && draw->pipeline.aapoint)
- wide_points = FALSE;
+ wide_points = false;
else if (rast->point_size > draw->pipeline.wide_point_threshold)
- wide_points = TRUE;
+ wide_points = true;
else if (rast->point_quad_rasterization && draw->pipeline.wide_point_sprites)
- wide_points = TRUE;
+ wide_points = true;
else
- wide_points = FALSE;
+ wide_points = false;
/*
* NOTE: we build up the pipeline in end-to-start order.
@@ -181,7 +181,7 @@ validate_pipeline(struct draw_stage *stage)
if ((!rast->multisample && rast->line_smooth) && draw->pipeline.aaline) {
draw->pipeline.aaline->next = next;
next = draw->pipeline.aaline;
- precalc_flat = TRUE;
+ precalc_flat = true;
}
if ((!rast->multisample && rast->point_smooth) && draw->pipeline.aapoint) {
@@ -192,7 +192,7 @@ validate_pipeline(struct draw_stage *stage)
if (wide_lines) {
draw->pipeline.wide_line->next = next;
next = draw->pipeline.wide_line;
- precalc_flat = TRUE;
+ precalc_flat = true;
}
if (wide_points) {
@@ -203,7 +203,7 @@ validate_pipeline(struct draw_stage *stage)
if (rast->line_stipple_enable && draw->pipeline.line_stipple) {
draw->pipeline.stipple->next = next;
next = draw->pipeline.stipple;
- precalc_flat = TRUE; /* only needed for lines really */
+ precalc_flat = true; /* only needed for lines really */
}
if (rast->poly_stipple_enable
@@ -216,8 +216,8 @@ validate_pipeline(struct draw_stage *stage)
rast->fill_back != PIPE_POLYGON_MODE_FILL) {
draw->pipeline.unfilled->next = next;
next = draw->pipeline.unfilled;
- precalc_flat = TRUE; /* only needed for triangles really */
- need_det = TRUE;
+ precalc_flat = true; /* only needed for triangles really */
+ need_det = true;
}
if (precalc_flat) {
@@ -234,13 +234,13 @@ validate_pipeline(struct draw_stage *stage)
rast->offset_tri) {
draw->pipeline.offset->next = next;
next = draw->pipeline.offset;
- need_det = TRUE;
+ need_det = true;
}
if (rast->light_twoside) {
draw->pipeline.twoside->next = next;
next = draw->pipeline.twoside;
- need_det = TRUE;
+ need_det = true;
}
/* Always run the cull stage as we calculate determinant there
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_vbuf.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
index ea180fb13..02f820746 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_vbuf.c
@@ -63,13 +63,13 @@ struct vbuf_stage {
/* FIXME: we have no guarantee that 'unsigned' is 32bit */
/** Vertices in hardware format */
- unsigned *vertices;
- unsigned *vertex_ptr;
+ uint8_t *vertices;
+ uint8_t *vertex_ptr;
unsigned max_vertices;
unsigned nr_vertices;
/** Indices */
- ushort *indices;
+ uint16_t *indices;
unsigned max_indices;
unsigned nr_indices;
@@ -115,7 +115,7 @@ check_space(struct vbuf_stage *vbuf, unsigned nr)
* have a couple of slots at the beginning (1-dword header, 4-dword
* clip pos) that we ignore here. We only use the vertex->data[] fields.
*/
-static inline ushort
+static inline uint16_t
emit_vertex(struct vbuf_stage *vbuf, struct vertex_header *vertex)
{
if (vertex->vertex_id == UNDEFINED_VERTEX_ID && vbuf->vertex_ptr) {
@@ -130,11 +130,11 @@ emit_vertex(struct vbuf_stage *vbuf, struct vertex_header *vertex)
if (0) draw_dump_emitted_vertex(vbuf->vinfo, (uint8_t *)vbuf->vertex_ptr);
- vbuf->vertex_ptr += vbuf->vertex_size/4;
+ vbuf->vertex_ptr += vbuf->vertex_size;
vertex->vertex_id = vbuf->nr_vertices++;
}
- return (ushort)vertex->vertex_id;
+ return (uint16_t)vertex->vertex_id;
}
@@ -183,7 +183,7 @@ vbuf_point(struct draw_stage *stage, struct prim_header *prim)
* will be flushed if needed and a new one allocated.
*/
static void
-vbuf_start_prim(struct vbuf_stage *vbuf, uint prim)
+vbuf_start_prim(struct vbuf_stage *vbuf, enum mesa_prim prim)
{
struct translate_key hw_key;
unsigned dst_offset;
@@ -270,7 +270,7 @@ vbuf_first_tri(struct draw_stage *stage, struct prim_header *prim)
struct vbuf_stage *vbuf = vbuf_stage(stage);
vbuf_flush_vertices(vbuf);
- vbuf_start_prim(vbuf, PIPE_PRIM_TRIANGLES);
+ vbuf_start_prim(vbuf, MESA_PRIM_TRIANGLES);
stage->tri = vbuf_tri;
stage->tri(stage, prim);
}
@@ -282,7 +282,7 @@ vbuf_first_line(struct draw_stage *stage, struct prim_header *prim)
struct vbuf_stage *vbuf = vbuf_stage(stage);
vbuf_flush_vertices(vbuf);
- vbuf_start_prim(vbuf, PIPE_PRIM_LINES);
+ vbuf_start_prim(vbuf, MESA_PRIM_LINES);
stage->line = vbuf_line;
stage->line(stage, prim);
}
@@ -294,7 +294,7 @@ vbuf_first_point(struct draw_stage *stage, struct prim_header *prim)
struct vbuf_stage *vbuf = vbuf_stage(stage);
vbuf_flush_vertices(vbuf);
- vbuf_start_prim(vbuf, PIPE_PRIM_POINTS);
+ vbuf_start_prim(vbuf, MESA_PRIM_POINTS);
stage->point = vbuf_point;
stage->point(stage, prim);
}
@@ -362,12 +362,11 @@ vbuf_alloc_vertices(struct vbuf_stage *vbuf)
* fail, we are basically without usable hardware.
*/
vbuf->render->allocate_vertices(vbuf->render,
- (ushort) vbuf->vertex_size,
- (ushort) vbuf->max_vertices);
+ (uint16_t) vbuf->vertex_size,
+ (uint16_t) vbuf->max_vertices);
- vbuf->vertices = (uint *) vbuf->render->map_vertices(vbuf->render);
-
- vbuf->vertex_ptr = vbuf->vertices;
+ vbuf->vertex_ptr = vbuf->vertices =
+ vbuf->render->map_vertices(vbuf->render);
}
@@ -429,7 +428,7 @@ draw_vbuf_stage(struct draw_context *draw, struct vbuf_render *render)
vbuf->render = render;
vbuf->max_indices = MIN2(render->max_indices, UNDEFINED_VERTEX_ID-1);
- vbuf->indices = (ushort *) align_malloc(vbuf->max_indices *
+ vbuf->indices = (uint16_t *) align_malloc(vbuf->max_indices *
sizeof(vbuf->indices[0]),
16);
if (!vbuf->indices)
@@ -439,8 +438,7 @@ draw_vbuf_stage(struct draw_context *draw, struct vbuf_render *render)
if (!vbuf->cache)
goto fail;
- vbuf->vertices = NULL;
- vbuf->vertex_ptr = vbuf->vertices;
+ vbuf->vertex_ptr = vbuf->vertices = NULL;
vbuf->zero4[0] = vbuf->zero4[1] = vbuf->zero4[2] = vbuf->zero4[3] = 0.0f;
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_wide_line.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
index 0f6c97a50..baf2f5fb7 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_wide_line.c
@@ -67,7 +67,7 @@ wideline_line(struct draw_stage *stage,
const float dx = fabsf(pos0[0] - pos2[0]);
const float dy = fabsf(pos0[1] - pos2[1]);
- const boolean half_pixel_center =
+ const bool half_pixel_center =
stage->draw->rasterizer->half_pixel_center;
/* small tweak to meet GL specification */
@@ -147,9 +147,9 @@ wideline_first_line(struct draw_stage *stage,
/* Disable triangle culling, stippling, unfilled mode etc. */
r = draw_get_rasterizer_no_cull(draw, rast);
- draw->suspend_flushing = TRUE;
+ draw->suspend_flushing = true;
pipe->bind_rasterizer_state(pipe, r);
- draw->suspend_flushing = FALSE;
+ draw->suspend_flushing = false;
stage->line = wideline_line;
@@ -168,9 +168,9 @@ wideline_flush(struct draw_stage *stage, unsigned flags)
/* restore original rasterizer state */
if (draw->rast_handle) {
- draw->suspend_flushing = TRUE;
+ draw->suspend_flushing = true;
pipe->bind_rasterizer_state(pipe, draw->rast_handle);
- draw->suspend_flushing = FALSE;
+ draw->suspend_flushing = false;
}
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_wide_point.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
index 0e8ccf565..d8254d470 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pipe_wide_point.c
@@ -72,8 +72,8 @@ struct widepoint_stage {
float ybias;
/** for automatic texcoord generation/replacement */
- uint num_texcoord_gen;
- uint texcoord_gen_slot[PIPE_MAX_SHADER_OUTPUTS];
+ unsigned num_texcoord_gen;
+ unsigned texcoord_gen_slot[PIPE_MAX_SHADER_OUTPUTS];
/* TGSI_SEMANTIC to which sprite_coord_enable applies */
enum tgsi_semantic sprite_coord_semantic;
@@ -101,10 +101,10 @@ set_texcoords(const struct widepoint_stage *wide,
{
const struct draw_context *draw = wide->stage.draw;
const struct pipe_rasterizer_state *rast = draw->rasterizer;
- const uint texcoord_mode = rast->sprite_coord_mode;
+ const unsigned texcoord_mode = rast->sprite_coord_mode;
for (unsigned i = 0; i < wide->num_texcoord_gen; i++) {
- const uint slot = wide->texcoord_gen_slot[i];
+ const unsigned slot = wide->texcoord_gen_slot[i];
v->data[slot][0] = tc[0];
if (texcoord_mode == PIPE_SPRITE_COORD_LOWER_LEFT)
v->data[slot][1] = 1.0f - tc[1];
@@ -127,7 +127,7 @@ widepoint_point(struct draw_stage *stage,
{
const struct widepoint_stage *wide = widepoint_stage(stage);
const unsigned pos = draw_current_shader_position_output(stage->draw);
- const boolean sprite = (boolean) stage->draw->rasterizer->point_quad_rasterization;
+ const bool sprite = (bool) stage->draw->rasterizer->point_quad_rasterization;
float half_size;
float left_adj, right_adj, bot_adj, top_adj;
@@ -215,9 +215,9 @@ widepoint_first_point(struct draw_stage *stage,
/* Disable triangle culling, stippling, unfilled mode etc. */
r = draw_get_rasterizer_no_cull(draw, rast);
- draw->suspend_flushing = TRUE;
+ draw->suspend_flushing = true;
pipe->bind_rasterizer_state(pipe, r);
- draw->suspend_flushing = FALSE;
+ draw->suspend_flushing = false;
/* XXX we won't know the real size if it's computed by the vertex shader! */
if ((rast->point_size > draw->pipeline.wide_point_threshold) ||
@@ -286,9 +286,9 @@ widepoint_flush(struct draw_stage *stage, unsigned flags)
/* restore original rasterizer state */
if (draw->rast_handle) {
- draw->suspend_flushing = TRUE;
+ draw->suspend_flushing = true;
pipe->bind_rasterizer_state(pipe, draw->rast_handle);
- draw->suspend_flushing = FALSE;
+ draw->suspend_flushing = false;
}
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler_tmp.h b/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler_tmp.h
index 8f6805090..2bfa4778c 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler_tmp.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_prim_assembler_tmp.h
@@ -7,11 +7,11 @@
#define FUNC_ENTER \
/* declare more local vars */ \
- const enum pipe_prim_type prim = input_prims->prim; \
+ const enum mesa_prim prim = input_prims->prim; \
const unsigned prim_flags = input_prims->flags; \
- const boolean last_vertex_last = !asmblr->draw->rasterizer->flatshade_first; \
+ const bool last_vertex_last = !asmblr->draw->rasterizer->flatshade_first; \
switch (prim) { \
- case PIPE_PRIM_POLYGON: \
+ case MESA_PRIM_POLYGON: \
assert(!"unexpected primitive type in prim assembler"); \
return; \
default: \
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_private.h b/lib/mesa/src/gallium/auxiliary/draw/draw_private.h
index 1780070fa..9d3a465c5 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_private.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_private.h
@@ -43,16 +43,19 @@
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
+#include "pipe/p_shader_tokens.h"
-#include "tgsi/tgsi_scan.h"
+#include "draw_vertex_header.h"
#ifdef DRAW_LLVM_AVAILABLE
struct gallivm_state;
#endif
-
-/** Sum of frustum planes and user-defined planes */
-#define DRAW_TOTAL_CLIP_PLANES (6 + PIPE_MAX_CLIP_PLANES)
+/**
+ * The max stage the draw stores resources for.
+ * i.e. vs, tcs, tes, gs. no fs/cs/ms/ts.
+ */
+#define DRAW_MAX_SHADER_STAGE (PIPE_SHADER_GEOMETRY + 1)
/**
* The largest possible index of a vertex that can be fetched.
@@ -102,6 +105,8 @@ struct tgsi_sampler;
struct tgsi_image;
struct tgsi_buffer;
struct lp_cached_code;
+struct draw_vertex_info;
+struct draw_prim_info;
/**
* Represents the mapped vertex buffer.
@@ -111,20 +116,6 @@ struct draw_vertex_buffer {
uint32_t size;
};
-/**
- * Basic vertex info. Used to represent vertices after VS (through GS, TESS,
- * etc.) to vbuf output.
- */
-struct vertex_header {
- unsigned clipmask:DRAW_TOTAL_CLIP_PLANES;
- unsigned edgeflag:1;
- unsigned pad:1;
- unsigned vertex_id:16;
-
- float clip_pos[4];
- float data[][4]; // the vertex attributes
-};
-
/* NOTE: It should match vertex_id size above */
#define UNDEFINED_VERTEX_ID 0xffff
@@ -132,6 +123,11 @@ struct vertex_header {
/* maximum number of shader variants we can cache */
#define DRAW_MAX_SHADER_VARIANTS 512
+struct draw_buffer_info {
+ const void *ptr;
+ unsigned size;
+};
+
/**
* Private context for the drawing module.
*/
@@ -163,9 +159,9 @@ struct draw_context
float wide_point_threshold; /**< convert pnts to tris if larger than this */
float wide_line_threshold; /**< convert lines to tris if wider than this */
- boolean wide_point_sprites; /**< convert points to tris for sprite mode */
- boolean line_stipple; /**< do line stipple? */
- boolean point_sprite; /**< convert points to quads for sprites? */
+ bool wide_point_sprites; /**< convert points to tris for sprite mode */
+ bool line_stipple; /**< do line stipple? */
+ bool point_sprite; /**< convert points to quads for sprites? */
/* Temporary storage while the pipeline is being run:
*/
@@ -181,17 +177,19 @@ struct draw_context
struct {
/* Current active frontend */
struct draw_pt_front_end *frontend;
- enum pipe_prim_type prim;
+ enum mesa_prim prim;
+ uint8_t vertices_per_patch;
+ bool rebind_parameters;
+
unsigned opt; /**< bitmask of PT_x flags */
unsigned eltSize; /* saved eltSize for flushing */
unsigned viewid; /* saved viewid for flushing */
- ubyte vertices_per_patch;
- boolean rebind_parameters;
struct {
struct draw_pt_middle_end *fetch_shade_emit;
struct draw_pt_middle_end *general;
struct draw_pt_middle_end *llvm;
+ struct draw_pt_middle_end *mesh;
} middle;
struct {
@@ -209,9 +207,13 @@ struct draw_context
*/
unsigned max_index;
+ unsigned vertex_strides[PIPE_MAX_ATTRIBS];
struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
unsigned nr_vertex_elements;
+ bool test_fse; /* enable FSE even though its not correct (eg for softpipe) */
+ bool no_fse; /* disable FSE even when it is correct */
+
/* user-space vertex data, buffers */
struct {
/** vertex element/index buffer (ex: glDrawElements) */
@@ -231,58 +233,41 @@ struct draw_context
struct draw_vertex_buffer vbuffer[PIPE_MAX_ATTRIBS];
/** constant buffers for each shader stage */
- const void *vs_constants[PIPE_MAX_CONSTANT_BUFFERS];
- unsigned vs_constants_size[PIPE_MAX_CONSTANT_BUFFERS];
- const void *gs_constants[PIPE_MAX_CONSTANT_BUFFERS];
- unsigned gs_constants_size[PIPE_MAX_CONSTANT_BUFFERS];
- const void *tcs_constants[PIPE_MAX_CONSTANT_BUFFERS];
- unsigned tcs_constants_size[PIPE_MAX_CONSTANT_BUFFERS];
- const void *tes_constants[PIPE_MAX_CONSTANT_BUFFERS];
- unsigned tes_constants_size[PIPE_MAX_CONSTANT_BUFFERS];
-
- /** shader buffers for each shader stage */
- const void *vs_ssbos[PIPE_MAX_SHADER_BUFFERS];
- unsigned vs_ssbos_size[PIPE_MAX_SHADER_BUFFERS];
- const void *gs_ssbos[PIPE_MAX_SHADER_BUFFERS];
- unsigned gs_ssbos_size[PIPE_MAX_SHADER_BUFFERS];
- const void *tcs_ssbos[PIPE_MAX_SHADER_BUFFERS];
- unsigned tcs_ssbos_size[PIPE_MAX_SHADER_BUFFERS];
- const void *tes_ssbos[PIPE_MAX_SHADER_BUFFERS];
- unsigned tes_ssbos_size[PIPE_MAX_SHADER_BUFFERS];
+ struct draw_buffer_info constants[DRAW_MAX_SHADER_STAGE][PIPE_MAX_CONSTANT_BUFFERS];
+ struct draw_buffer_info ssbos[DRAW_MAX_SHADER_STAGE][PIPE_MAX_SHADER_BUFFERS];
/* pointer to planes */
float (*planes)[DRAW_TOTAL_CLIP_PLANES][4];
} user;
-
- boolean test_fse; /* enable FSE even though its not correct (eg for softpipe) */
- boolean no_fse; /* disable FSE even when it is correct */
} pt;
struct {
- boolean bypass_clip_xy;
- boolean bypass_clip_z;
- boolean guard_band_xy;
- boolean bypass_clip_points;
+ bool bypass_clip_xy;
+ bool bypass_clip_z;
+ bool guard_band_xy;
+ bool bypass_clip_points_lines;
} driver;
- boolean quads_always_flatshade_last;
+ bool quads_always_flatshade_last;
- boolean flushing; /**< debugging/sanity */
- boolean suspend_flushing; /**< internally set */
+ bool flushing; /**< debugging/sanity */
+ bool suspend_flushing; /**< internally set */
/* Flags set if API requires clipping in these planes and the
* driver doesn't indicate that it can do it for us.
*/
- boolean clip_xy;
- boolean clip_z;
- boolean clip_user;
- boolean guard_band_xy;
- boolean guard_band_points_xy;
+ bool clip_xy;
+ bool clip_z;
+ bool clip_user;
+ bool guard_band_xy;
+ bool guard_band_points_lines_xy;
- boolean dump_vs;
+ bool dump_vs;
+ bool identity_viewport;
+ bool bypass_viewport;
/** Depth format and bias related settings. */
- boolean floating_point_depth;
+ bool floating_point_depth;
double mrd; /**< minimum resolvable depth value, for polygon offset */
/** Current rasterizer state given to us by the driver */
@@ -294,17 +279,15 @@ struct draw_context
void *rasterizer_no_cull[2][2][2];
struct pipe_viewport_state viewports[PIPE_MAX_VIEWPORTS];
- boolean identity_viewport;
- boolean bypass_viewport;
/** Vertex shader state */
struct {
struct draw_vertex_shader *vertex_shader;
- uint num_vs_outputs; /**< convenience, from vertex_shader */
- uint position_output;
- uint edgeflag_output;
- uint clipvertex_output;
- uint ccdistance_output[2];
+ unsigned num_vs_outputs; /**< convenience, from vertex_shader */
+ unsigned position_output;
+ unsigned edgeflag_output;
+ unsigned clipvertex_output;
+ unsigned ccdistance_output[2];
/** Fields for TGSI interpreter / execution */
struct {
@@ -324,9 +307,9 @@ struct draw_context
/** Geometry shader state */
struct {
struct draw_geometry_shader *geometry_shader;
- uint num_gs_outputs; /**< convenience, from geometry_shader */
- uint position_output;
- uint clipvertex_output;
+ unsigned num_gs_outputs; /**< convenience, from geometry_shader */
+ unsigned position_output;
+ unsigned clipvertex_output;
/** Fields for TGSI interpreter / execution */
struct {
@@ -341,31 +324,13 @@ struct draw_context
/* Tessellation state */
struct {
struct draw_tess_ctrl_shader *tess_ctrl_shader;
-
- /** Fields for TGSI interpreter / execution */
- struct {
- struct tgsi_exec_machine *machine;
-
- struct tgsi_sampler *sampler;
- struct tgsi_image *image;
- struct tgsi_buffer *buffer;
- } tgsi;
} tcs;
struct {
struct draw_tess_eval_shader *tess_eval_shader;
- uint num_tes_outputs; /**< convenience, from tess_eval_shader */
- uint position_output;
- uint clipvertex_output;
-
- /** Fields for TGSI interpreter / execution */
- struct {
- struct tgsi_exec_machine *machine;
-
- struct tgsi_sampler *sampler;
- struct tgsi_image *image;
- struct tgsi_buffer *buffer;
- } tgsi;
+ unsigned num_tes_outputs; /**< convenience, from tess_eval_shader */
+ unsigned position_output;
+ unsigned clipvertex_output;
} tes;
/** Fragment shader state */
@@ -373,10 +338,17 @@ struct draw_context
struct draw_fragment_shader *fragment_shader;
} fs;
+ struct {
+ struct draw_mesh_shader *mesh_shader;
+ unsigned num_ms_outputs; /**< convenience, from geometry_shader */
+ unsigned position_output;
+ unsigned clipvertex_output;
+ } ms;
+
/** Stream output (vertex feedback) state */
struct {
struct draw_so_target *targets[PIPE_MAX_SO_BUFFERS];
- uint num_targets;
+ unsigned num_targets;
} so;
/* Clip derived state:
@@ -386,10 +358,10 @@ struct draw_context
/* If a prim stage introduces new vertex attributes, they'll be stored here
*/
struct {
- uint num;
- uint semantic_name[DRAW_MAX_EXTRA_SHADER_OUTPUTS];
- uint semantic_index[DRAW_MAX_EXTRA_SHADER_OUTPUTS];
- uint slot[DRAW_MAX_EXTRA_SHADER_OUTPUTS];
+ unsigned num;
+ enum tgsi_semantic semantic_name[DRAW_MAX_EXTRA_SHADER_OUTPUTS];
+ unsigned semantic_index[DRAW_MAX_EXTRA_SHADER_OUTPUTS];
+ unsigned slot[DRAW_MAX_EXTRA_SHADER_OUTPUTS];
} extra_shader_outputs;
unsigned instance_id;
@@ -403,20 +375,20 @@ struct draw_context
* we only handle vertex and geometry shaders in the draw module, but
* there may be more in the future (ex: hull and tessellation).
*/
- struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
- unsigned num_sampler_views[PIPE_SHADER_TYPES];
- const struct pipe_sampler_state *samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS];
- unsigned num_samplers[PIPE_SHADER_TYPES];
+ struct pipe_sampler_view *sampler_views[DRAW_MAX_SHADER_STAGE][PIPE_MAX_SHADER_SAMPLER_VIEWS];
+ unsigned num_sampler_views[DRAW_MAX_SHADER_STAGE];
+ const struct pipe_sampler_state *samplers[DRAW_MAX_SHADER_STAGE][PIPE_MAX_SAMPLERS];
+ unsigned num_samplers[DRAW_MAX_SHADER_STAGE];
- struct pipe_image_view *images[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_IMAGES];
- unsigned num_images[PIPE_SHADER_TYPES];
+ struct pipe_image_view *images[DRAW_MAX_SHADER_STAGE][PIPE_MAX_SHADER_IMAGES];
+ unsigned num_images[DRAW_MAX_SHADER_STAGE];
struct pipe_query_data_pipeline_statistics statistics;
- boolean collect_statistics;
+ bool collect_statistics;
+ bool collect_primgen;
float default_outer_tess_level[4];
float default_inner_tess_level[2];
- bool collect_primgen;
struct draw_assembler *ia;
@@ -433,55 +405,34 @@ struct draw_context
struct draw_fetch_info {
- boolean linear;
+ bool linear;
unsigned start;
const unsigned *elts;
unsigned count;
};
-struct draw_vertex_info {
- struct vertex_header *verts;
- unsigned vertex_size;
- unsigned stride;
- unsigned count;
-};
-
/* these flags are set if the primitive is a segment of a larger one */
#define DRAW_SPLIT_BEFORE 0x1
#define DRAW_SPLIT_AFTER 0x2
#define DRAW_LINE_LOOP_AS_STRIP 0x4
-struct draw_prim_info {
- boolean linear;
- unsigned start;
-
- const ushort *elts;
- unsigned count;
-
- enum pipe_prim_type prim;
- unsigned flags;
- unsigned *primitive_lengths;
- unsigned primitive_count;
-};
-
-
/*******************************************************************************
* Draw common initialization code
*/
-boolean draw_init(struct draw_context *draw);
+bool draw_init(struct draw_context *draw);
void draw_new_instance(struct draw_context *draw);
/*******************************************************************************
* Vertex shader code:
*/
-boolean draw_vs_init(struct draw_context *draw);
+bool draw_vs_init(struct draw_context *draw);
void draw_vs_destroy(struct draw_context *draw);
/*******************************************************************************
* Geometry shading code:
*/
-boolean draw_gs_init(struct draw_context *draw);
+bool draw_gs_init(struct draw_context *draw);
void draw_gs_destroy(struct draw_context *draw);
@@ -489,24 +440,25 @@ void draw_gs_destroy(struct draw_context *draw);
/*******************************************************************************
* Common shading code:
*/
-uint draw_current_shader_outputs(const struct draw_context *draw);
-uint draw_current_shader_position_output(const struct draw_context *draw);
-uint draw_current_shader_viewport_index_output(const struct draw_context *draw);
-uint draw_current_shader_clipvertex_output(const struct draw_context *draw);
-uint draw_current_shader_ccdistance_output(const struct draw_context *draw, int index);
-uint draw_current_shader_num_written_clipdistances(const struct draw_context *draw);
-uint draw_current_shader_num_written_culldistances(const struct draw_context *draw);
+unsigned draw_current_shader_outputs(const struct draw_context *draw);
+unsigned draw_current_shader_position_output(const struct draw_context *draw);
+unsigned draw_current_shader_viewport_index_output(const struct draw_context *draw);
+unsigned draw_current_shader_clipvertex_output(const struct draw_context *draw);
+unsigned draw_current_shader_ccdistance_output(const struct draw_context *draw, int index);
+unsigned draw_current_shader_num_written_clipdistances(const struct draw_context *draw);
+unsigned draw_current_shader_num_written_culldistances(const struct draw_context *draw);
int draw_alloc_extra_vertex_attrib(struct draw_context *draw,
- uint semantic_name, uint semantic_index);
+ enum tgsi_semantic semantic_name,
+ unsigned semantic_index);
void draw_remove_extra_vertex_attribs(struct draw_context *draw);
-boolean draw_current_shader_uses_viewport_index(
+bool draw_current_shader_uses_viewport_index(
const struct draw_context *draw);
/*******************************************************************************
* Vertex processing (was passthrough) code:
*/
-boolean draw_pt_init(struct draw_context *draw);
+bool draw_pt_init(struct draw_context *draw);
void draw_pt_destroy(struct draw_context *draw);
void draw_pt_reset_vertex_ids(struct draw_context *draw);
void draw_pt_flush(struct draw_context *draw, unsigned flags);
@@ -516,7 +468,7 @@ void draw_pt_flush(struct draw_context *draw, unsigned flags);
* Primitive processing (pipeline) code:
*/
-boolean draw_pipeline_init(struct draw_context *draw);
+bool draw_pipeline_init(struct draw_context *draw);
void draw_pipeline_destroy(struct draw_context *draw);
/*
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pt.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pt.c
index 3d5d5f088..01f11ed10 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pt.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pt.c
@@ -44,8 +44,8 @@
#include "util/u_draw.h"
-DEBUG_GET_ONCE_BOOL_OPTION(draw_fse, "DRAW_FSE", FALSE)
-DEBUG_GET_ONCE_BOOL_OPTION(draw_no_fse, "DRAW_NO_FSE", FALSE)
+DEBUG_GET_ONCE_BOOL_OPTION(draw_fse, "DRAW_FSE", false)
+DEBUG_GET_ONCE_BOOL_OPTION(draw_no_fse, "DRAW_NO_FSE", false)
/* Overall we split things into:
@@ -54,14 +54,14 @@ DEBUG_GET_ONCE_BOOL_OPTION(draw_no_fse, "DRAW_NO_FSE", FALSE)
* - pipeline -- the prim pipeline: clipping, wide lines, etc
* - backend -- the vbuf_render provided by the driver.
*/
-static boolean
+static bool
draw_pt_arrays(struct draw_context *draw,
- enum pipe_prim_type prim,
+ enum mesa_prim prim,
bool index_bias_varies,
const struct pipe_draw_start_count_bias *draw_info,
unsigned num_draws)
{
- enum pipe_prim_type out_prim = prim;
+ enum mesa_prim out_prim = prim;
if (draw->gs.geometry_shader)
out_prim = draw->gs.geometry_shader->output_primitive;
@@ -129,7 +129,7 @@ draw_pt_arrays(struct draw_context *draw,
if (draw->pt.rebind_parameters) {
/* update constants, viewport dims, clip planes, etc */
middle->bind_parameters(middle);
- draw->pt.rebind_parameters = FALSE;
+ draw->pt.rebind_parameters = false;
}
for (unsigned i = 0; i < num_draws; i++) {
@@ -137,7 +137,7 @@ draw_pt_arrays(struct draw_context *draw,
*/
unsigned first, incr;
- if (prim == PIPE_PRIM_PATCHES) {
+ if (prim == MESA_PRIM_PATCHES) {
first = draw->pt.vertices_per_patch;
incr = draw->pt.vertices_per_patch;
} else {
@@ -164,7 +164,7 @@ draw_pt_arrays(struct draw_context *draw,
draw->pt.user.drawid++;
}
- return TRUE;
+ return true;
}
@@ -182,12 +182,12 @@ draw_pt_flush(struct draw_context *draw, unsigned flags)
}
if (flags & DRAW_FLUSH_PARAMETER_CHANGE) {
- draw->pt.rebind_parameters = TRUE;
+ draw->pt.rebind_parameters = true;
}
}
-boolean
+bool
draw_pt_init(struct draw_context *draw)
{
draw->pt.test_fse = debug_get_option_draw_fse();
@@ -195,28 +195,35 @@ draw_pt_init(struct draw_context *draw)
draw->pt.front.vsplit = draw_pt_vsplit(draw);
if (!draw->pt.front.vsplit)
- return FALSE;
+ return false;
draw->pt.middle.fetch_shade_emit = draw_pt_middle_fse(draw);
if (!draw->pt.middle.fetch_shade_emit)
- return FALSE;
+ return false;
draw->pt.middle.general = draw_pt_fetch_pipeline_or_emit(draw);
if (!draw->pt.middle.general)
- return FALSE;
+ return false;
#ifdef DRAW_LLVM_AVAILABLE
- if (draw->llvm)
+ if (draw->llvm) {
draw->pt.middle.llvm = draw_pt_fetch_pipeline_or_emit_llvm(draw);
+ draw->pt.middle.mesh = draw_pt_mesh_pipeline_or_emit(draw);
+ }
#endif
- return TRUE;
+ return true;
}
void
draw_pt_destroy(struct draw_context *draw)
{
+ if (draw->pt.middle.mesh) {
+ draw->pt.middle.mesh->destroy(draw->pt.middle.mesh);
+ draw->pt.middle.mesh = NULL;
+ }
+
if (draw->pt.middle.llvm) {
draw->pt.middle.llvm->destroy(draw->pt.middle.llvm);
draw->pt.middle.llvm = NULL;
@@ -243,14 +250,14 @@ draw_pt_destroy(struct draw_context *draw)
* Debug- print the first 'count' vertices.
*/
static void
-draw_print_arrays(struct draw_context *draw, enum pipe_prim_type prim,
- int start, uint count, int index_bias)
+draw_print_arrays(struct draw_context *draw, enum mesa_prim prim,
+ int start, unsigned count, int index_bias)
{
debug_printf("Draw arrays(prim = %u, start = %u, count = %u)\n",
prim, start, count);
for (unsigned i = 0; i < count; i++) {
- uint ii = 0;
+ unsigned ii = 0;
if (draw->pt.user.eltSize) {
/* indexed arrays */
@@ -258,19 +265,19 @@ draw_print_arrays(struct draw_context *draw, enum pipe_prim_type prim,
switch (draw->pt.user.eltSize) {
case 1:
{
- const ubyte *elem = (const ubyte *) draw->pt.user.elts;
+ const uint8_t *elem = (const uint8_t *) draw->pt.user.elts;
ii = elem[start + i];
}
break;
case 2:
{
- const ushort *elem = (const ushort *) draw->pt.user.elts;
+ const uint16_t *elem = (const uint16_t *) draw->pt.user.elts;
ii = elem[start + i];
}
break;
case 4:
{
- const uint *elem = (const uint *) draw->pt.user.elts;
+ const uint32_t *elem = (const uint32_t *) draw->pt.user.elts;
ii = elem[start + i];
}
break;
@@ -289,15 +296,15 @@ draw_print_arrays(struct draw_context *draw, enum pipe_prim_type prim,
}
for (unsigned j = 0; j < draw->pt.nr_vertex_elements; j++) {
- uint buf = draw->pt.vertex_element[j].vertex_buffer_index;
- ubyte *ptr = (ubyte *) draw->pt.user.vbuffer[buf].map;
+ unsigned buf = draw->pt.vertex_element[j].vertex_buffer_index;
+ uint8_t *ptr = (uint8_t *) draw->pt.user.vbuffer[buf].map;
if (draw->pt.vertex_element[j].instance_divisor) {
ii = draw->instance_id / draw->pt.vertex_element[j].instance_divisor;
}
ptr += draw->pt.vertex_buffer[buf].buffer_offset;
- ptr += draw->pt.vertex_buffer[buf].stride * ii;
+ ptr += draw->pt.vertex_element[j].src_stride * ii;
ptr += draw->pt.vertex_element[j].src_offset;
debug_printf(" Attr %u: ", j);
@@ -329,14 +336,14 @@ draw_print_arrays(struct draw_context *draw, enum pipe_prim_type prim,
break;
case PIPE_FORMAT_B8G8R8A8_UNORM:
{
- ubyte *u = (ubyte *) ptr;
+ uint8_t *u = (uint8_t *) ptr;
debug_printf("BGRA %d %d %d %d @ %p\n", u[0], u[1], u[2], u[3],
(void *) u);
}
break;
case PIPE_FORMAT_A8R8G8B8_UNORM:
{
- ubyte *u = (ubyte *) ptr;
+ uint8_t *u = (uint8_t *) ptr;
debug_printf("ARGB %d %d %d %d @ %p\n", u[0], u[1], u[2], u[3],
(void *) u);
}
@@ -437,7 +444,8 @@ resolve_draw_info(const struct pipe_draw_info *raw_info,
const struct pipe_draw_start_count_bias *raw_draw,
struct pipe_draw_info *info,
struct pipe_draw_start_count_bias *draw,
- struct pipe_vertex_buffer *vertex_buffer)
+ struct pipe_vertex_buffer *vertex_buffer,
+ struct pipe_vertex_element *vertex_element)
{
*info = *raw_info;
*draw = *raw_draw;
@@ -445,8 +453,8 @@ resolve_draw_info(const struct pipe_draw_info *raw_info,
struct draw_so_target *target =
(struct draw_so_target *)indirect->count_from_stream_output;
assert(vertex_buffer != NULL);
- draw->count = vertex_buffer->stride == 0 ? 0 :
- target->internal_offset / vertex_buffer->stride;
+ draw->count = vertex_element->src_stride == 0 ? 0 :
+ target->internal_offset / vertex_element->src_stride;
/* Stream output draw can not be indexed */
assert(!info->index_size);
@@ -520,7 +528,8 @@ draw_vbo(struct draw_context *draw,
if (indirect && indirect->count_from_stream_output) {
resolve_draw_info(info, indirect, &draws[0], &resolved_info,
- &resolved_draw, &(draw->pt.vertex_buffer[0]));
+ &resolved_draw, &(draw->pt.vertex_buffer[0]),
+ &(draw->pt.vertex_element[0]));
use_info = &resolved_info;
use_draws = &resolved_draw;
num_draws = 1;
@@ -555,18 +564,18 @@ draw_vbo(struct draw_context *draw,
if (0) {
debug_printf("Elements:\n");
for (unsigned i = 0; i < draw->pt.nr_vertex_elements; i++) {
- debug_printf(" %u: src_offset=%u inst_div=%u vbuf=%u format=%s\n",
+ debug_printf(" %u: src_offset=%u src_stride=%u inst_div=%u vbuf=%u format=%s\n",
i,
draw->pt.vertex_element[i].src_offset,
+ draw->pt.vertex_element[i].src_stride,
draw->pt.vertex_element[i].instance_divisor,
draw->pt.vertex_element[i].vertex_buffer_index,
util_format_name(draw->pt.vertex_element[i].src_format));
}
debug_printf("Buffers:\n");
for (unsigned i = 0; i < draw->pt.nr_vertex_buffers; i++) {
- debug_printf(" %u: stride=%u offset=%u size=%d ptr=%p\n",
+ debug_printf(" %u: offset=%u size=%d ptr=%p\n",
i,
- draw->pt.vertex_buffer[i].stride,
draw->pt.vertex_buffer[i].buffer_offset,
(int) draw->pt.user.vbuffer[i].size,
draw->pt.user.vbuffer[i].map);
@@ -625,3 +634,22 @@ draw_vbo(struct draw_context *draw,
}
util_fpstate_set(fpstate);
}
+
+/* to be called after a mesh shader is run */
+void
+draw_mesh(struct draw_context *draw,
+ struct draw_vertex_info *vert_info,
+ struct draw_prim_info *prim_info)
+{
+ struct draw_pt_middle_end *middle = draw->pt.middle.mesh;
+
+ draw->pt.user.eltSize = 0;
+ draw->pt.user.viewid = 0;
+ draw->pt.user.drawid = 0;
+ draw->pt.user.increment_draw_id = false;
+ draw->pt.vertices_per_patch = 0;
+
+ middle->prepare(middle, 0, 0, NULL);
+
+ draw_mesh_middle_end_run(middle, vert_info, prim_info);
+}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
index edaa78af3..940fec5cf 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c
@@ -53,7 +53,7 @@ struct llvm_middle_end {
unsigned vertex_data_offset;
unsigned vertex_size;
- enum pipe_prim_type input_prim;
+ enum mesa_prim input_prim;
unsigned opt;
struct draw_llvm *llvm;
@@ -275,7 +275,7 @@ llvm_middle_end_prepare_tes(struct llvm_middle_end *fpme)
*/
static void
llvm_middle_end_prepare(struct draw_pt_middle_end *middle,
- enum pipe_prim_type in_prim,
+ enum mesa_prim in_prim,
unsigned opt,
unsigned *max_vertices)
{
@@ -286,11 +286,13 @@ llvm_middle_end_prepare(struct draw_pt_middle_end *middle,
struct draw_geometry_shader *gs = draw->gs.geometry_shader;
struct draw_tess_ctrl_shader *tcs = draw->tcs.tess_ctrl_shader;
struct draw_tess_eval_shader *tes = draw->tes.tess_eval_shader;
- const enum pipe_prim_type out_prim =
+ const enum mesa_prim out_prim =
gs ? gs->output_primitive : tes ? get_tes_output_prim(tes) :
u_assembled_prim(in_prim);
- unsigned point_clip = draw->rasterizer->fill_front == PIPE_POLYGON_MODE_POINT ||
- out_prim == PIPE_PRIM_POINTS;
+ unsigned point_line_clip = draw->rasterizer->fill_front == PIPE_POLYGON_MODE_POINT ||
+ draw->rasterizer->fill_front == PIPE_POLYGON_MODE_LINE ||
+ out_prim == MESA_PRIM_POINTS ||
+ u_reduced_prim(out_prim) == MESA_PRIM_LINES;
fpme->input_prim = in_prim;
fpme->opt = opt;
@@ -299,11 +301,11 @@ llvm_middle_end_prepare(struct draw_pt_middle_end *middle,
draw->clip_xy,
draw->clip_z,
draw->clip_user,
- point_clip ? draw->guard_band_points_xy :
- draw->guard_band_xy,
+ point_line_clip ? draw->guard_band_points_lines_xy :
+ draw->guard_band_xy,
draw->bypass_viewport,
draw->rasterizer->clip_halfz,
- (draw->vs.edgeflag_output ? TRUE : FALSE));
+ (draw->vs.edgeflag_output ? true : false));
draw_pt_so_emit_prepare(fpme->so_emit, (gs == NULL && tes == NULL));
@@ -404,9 +406,9 @@ llvm_middle_end_prepare(struct draw_pt_middle_end *middle,
static unsigned
-get_num_consts_robust(struct draw_context *draw, unsigned *sizes, unsigned idx)
+get_num_consts_robust(struct draw_context *draw, struct draw_buffer_info *bufs, unsigned idx)
{
- uint64_t const_bytes = sizes[idx];
+ uint64_t const_bytes = bufs[idx].size;
if (const_bytes < sizeof(float))
return 0;
@@ -414,7 +416,6 @@ get_num_consts_robust(struct draw_context *draw, unsigned *sizes, unsigned idx)
return DIV_ROUND_UP(const_bytes, draw->constant_buffer_stride);
}
-
/**
* Bind/update constant buffer pointers, clip planes and viewport dims.
* These are "light weight" parameters which aren't baked into the
@@ -430,91 +431,39 @@ llvm_middle_end_bind_parameters(struct draw_pt_middle_end *middle)
struct draw_llvm *llvm = fpme->llvm;
unsigned i;
- for (i = 0; i < ARRAY_SIZE(llvm->jit_context.constants); ++i) {
- /*
- * There could be a potential issue with rounding this up, as the
- * shader expects 16-byte allocations, the fix is likely to move
- * to LOAD intrinsic in the future and remove the vec4 constraint.
- */
- int num_consts = get_num_consts_robust(draw, draw->pt.user.vs_constants_size, i);
- llvm->jit_context.constants[i].f = draw->pt.user.vs_constants[i];
- llvm->jit_context.constants[i].num_elements = num_consts;
- if (num_consts == 0) {
- llvm->jit_context.constants[i].f = fake_const_buf;
- }
- }
- for (i = 0; i < ARRAY_SIZE(llvm->jit_context.ssbos); ++i) {
- int num_ssbos = draw->pt.user.vs_ssbos_size[i];
- llvm->jit_context.ssbos[i].u = draw->pt.user.vs_ssbos[i];
- llvm->jit_context.ssbos[i].num_elements = num_ssbos;
- if (num_ssbos == 0) {
- llvm->jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
- }
- }
-
- for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.constants); ++i) {
- int num_consts = get_num_consts_robust(draw, draw->pt.user.gs_constants_size, i);
- llvm->gs_jit_context.constants[i].f = draw->pt.user.gs_constants[i];
- llvm->gs_jit_context.constants[i].num_elements = num_consts;
- if (num_consts == 0) {
- llvm->gs_jit_context.constants[i].f = fake_const_buf;
- }
- }
- for (i = 0; i < ARRAY_SIZE(llvm->gs_jit_context.ssbos); ++i) {
- int num_ssbos = draw->pt.user.gs_ssbos_size[i];
- llvm->gs_jit_context.ssbos[i].u = draw->pt.user.gs_ssbos[i];
- llvm->gs_jit_context.ssbos[i].num_elements = num_ssbos;
- if (num_ssbos == 0) {
- llvm->gs_jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
- }
- }
-
- for (i = 0; i < ARRAY_SIZE(llvm->tcs_jit_context.constants); ++i) {
- int num_consts = get_num_consts_robust(draw, draw->pt.user.tcs_constants_size, i);
- llvm->tcs_jit_context.constants[i].f = draw->pt.user.tcs_constants[i];
- llvm->tcs_jit_context.constants[i].num_elements = num_consts;
- if (num_consts == 0) {
- llvm->tcs_jit_context.constants[i].f = fake_const_buf;
+ for (enum pipe_shader_type shader_type = PIPE_SHADER_VERTEX; shader_type <= PIPE_SHADER_GEOMETRY; shader_type++) {
+ for (i = 0; i < ARRAY_SIZE(llvm->jit_resources[shader_type].constants); ++i) {
+ /*
+ * There could be a potential issue with rounding this up, as the
+ * shader expects 16-byte allocations, the fix is likely to move
+ * to LOAD intrinsic in the future and remove the vec4 constraint.
+ */
+ int num_consts = get_num_consts_robust(draw, draw->pt.user.constants[shader_type], i);
+ llvm->jit_resources[shader_type].constants[i].f = draw->pt.user.constants[shader_type][i].ptr;
+ llvm->jit_resources[shader_type].constants[i].num_elements = num_consts;
+ if (num_consts == 0) {
+ llvm->jit_resources[shader_type].constants[i].f = fake_const_buf;
+ }
}
- }
- for (i = 0; i < ARRAY_SIZE(llvm->tcs_jit_context.ssbos); ++i) {
- int num_ssbos = draw->pt.user.tcs_ssbos_size[i];
- llvm->tcs_jit_context.ssbos[i].u = draw->pt.user.tcs_ssbos[i];
- llvm->tcs_jit_context.ssbos[i].num_elements = num_ssbos;
- if (num_ssbos == 0) {
- llvm->tcs_jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
+ for (i = 0; i < ARRAY_SIZE(llvm->jit_resources[shader_type].ssbos); ++i) {
+ int num_ssbos = draw->pt.user.ssbos[shader_type][i].size;
+ llvm->jit_resources[shader_type].ssbos[i].u = draw->pt.user.ssbos[shader_type][i].ptr;
+ llvm->jit_resources[shader_type].ssbos[i].num_elements = num_ssbos;
+ if (num_ssbos == 0) {
+ llvm->jit_resources[shader_type].ssbos[i].u = (const uint32_t *)fake_const_buf;
+ }
}
- }
- for (i = 0; i < ARRAY_SIZE(llvm->tes_jit_context.constants); ++i) {
- int num_consts = get_num_consts_robust(draw, draw->pt.user.tes_constants_size, i);
- llvm->tes_jit_context.constants[i].f = draw->pt.user.tes_constants[i];
- llvm->tes_jit_context.constants[i].num_elements = num_consts;
- if (num_consts == 0) {
- llvm->tes_jit_context.constants[i].f = fake_const_buf;
- }
- }
- for (i = 0; i < ARRAY_SIZE(llvm->tes_jit_context.ssbos); ++i) {
- int num_ssbos = draw->pt.user.tes_ssbos_size[i];
- llvm->tes_jit_context.ssbos[i].u = draw->pt.user.tes_ssbos[i];
- llvm->tes_jit_context.ssbos[i].num_elements = num_ssbos;
- if (num_ssbos == 0) {
- llvm->tes_jit_context.ssbos[i].u = (const uint32_t *)fake_const_buf;
- }
+ llvm->jit_resources[shader_type].aniso_filter_table = lp_build_sample_aniso_filter_table();
}
- llvm->jit_context.planes =
+ llvm->vs_jit_context.planes =
(float (*)[DRAW_TOTAL_CLIP_PLANES][4]) draw->pt.user.planes[0];
llvm->gs_jit_context.planes =
(float (*)[DRAW_TOTAL_CLIP_PLANES][4]) draw->pt.user.planes[0];
- llvm->jit_context.viewports = draw->viewports;
+ llvm->vs_jit_context.viewports = draw->viewports;
llvm->gs_jit_context.viewports = draw->viewports;
-
- llvm->jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
- llvm->gs_jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
- llvm->tcs_jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
- llvm->tes_jit_context.aniso_filter_table = lp_build_sample_aniso_filter_table();
}
@@ -562,10 +511,10 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
struct draw_prim_info ia_prim_info;
struct draw_vertex_info ia_vert_info;
const struct draw_prim_info *prim_info = in_prim_info;
- boolean free_prim_info = FALSE;
+ bool free_prim_info = false;
unsigned opt = fpme->opt;
- boolean clipped = 0;
- ushort *tes_elts_out = NULL;
+ bool clipped = 0;
+ uint16_t *tes_elts_out = NULL;
assert(fetch_info->count > 0);
@@ -583,7 +532,7 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
if (draw->collect_statistics) {
draw->statistics.ia_vertices += prim_info->count;
- if (prim_info->prim == PIPE_PRIM_PATCHES)
+ if (prim_info->prim == MESA_PRIM_PATCHES)
draw->statistics.ia_primitives +=
prim_info->count / draw->pt.vertices_per_patch;
else
@@ -606,7 +555,8 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
elts = fetch_info->elts;
}
/* Run vertex fetch shader */
- clipped = fpme->current_variant->jit_func(&fpme->llvm->jit_context,
+ clipped = fpme->current_variant->jit_func(&fpme->llvm->vs_jit_context,
+ &fpme->llvm->jit_resources[PIPE_SHADER_VERTEX],
llvm_vert_info.verts,
draw->pt.user.vbuffer,
fetch_info->count,
@@ -625,13 +575,10 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
vert_info = &llvm_vert_info;
}
-
if (opt & PT_SHADE) {
struct draw_vertex_shader *vshader = draw->vs.vertex_shader;
if (tcs_shader) {
draw_tess_ctrl_shader_run(tcs_shader,
- draw->pt.user.tcs_constants,
- draw->pt.user.tcs_constants_size,
vert_info,
prim_info,
&vshader->info,
@@ -650,8 +597,6 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
if (tes_shader) {
draw_tess_eval_shader_run(tes_shader,
- draw->pt.user.tes_constants,
- draw->pt.user.tes_constants_size,
tcs_shader ? tcs_shader->vertices_out : draw->pt.vertices_per_patch,
vert_info,
prim_info,
@@ -662,7 +607,7 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
FREE(vert_info->verts);
vert_info = &tes_vert_info;
prim_info = &tes_prim_info;
- free_prim_info = TRUE;
+ free_prim_info = true;
/*
* pt emit can only handle ushort number of vertices (see
@@ -682,8 +627,7 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
if ((opt & PT_SHADE) && gshader) {
struct draw_vertex_shader *vshader = draw->vs.vertex_shader;
draw_geometry_shader_run(gshader,
- draw->pt.user.gs_constants,
- draw->pt.user.gs_constants_size,
+ draw->pt.user.constants[PIPE_SHADER_GEOMETRY],
vert_info,
prim_info,
tes_shader ? &tes_shader->info : &vshader->info,
@@ -697,7 +641,7 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
}
vert_info = &gs_vert_info[0];
prim_info = &gs_prim_info[0];
- free_prim_info = FALSE;
+ free_prim_info = false;
/*
* pt emit can only handle ushort number of vertices (see
* render->allocate_vertices).
@@ -722,7 +666,7 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
}
vert_info = &ia_vert_info;
prim_info = &ia_prim_info;
- free_prim_info = TRUE;
+ free_prim_info = true;
}
}
}
@@ -773,11 +717,11 @@ llvm_pipeline_generic(struct draw_pt_middle_end *middle,
}
-static inline enum pipe_prim_type
-prim_type(enum pipe_prim_type prim, unsigned flags)
+static inline enum mesa_prim
+prim_type(enum mesa_prim prim, unsigned flags)
{
if (flags & DRAW_LINE_LOOP_AS_STRIP)
- return PIPE_PRIM_LINE_STRIP;
+ return MESA_PRIM_LINE_STRIP;
else
return prim;
}
@@ -787,7 +731,7 @@ static void
llvm_middle_end_run(struct draw_pt_middle_end *middle,
const unsigned *fetch_elts,
unsigned fetch_count,
- const ushort *draw_elts,
+ const uint16_t *draw_elts,
unsigned draw_count,
unsigned prim_flags)
{
@@ -795,12 +739,12 @@ llvm_middle_end_run(struct draw_pt_middle_end *middle,
struct draw_fetch_info fetch_info;
struct draw_prim_info prim_info;
- fetch_info.linear = FALSE;
+ fetch_info.linear = false;
fetch_info.start = 0;
fetch_info.elts = fetch_elts;
fetch_info.count = fetch_count;
- prim_info.linear = FALSE;
+ prim_info.linear = false;
prim_info.start = 0;
prim_info.count = draw_count;
prim_info.elts = draw_elts;
@@ -823,12 +767,12 @@ llvm_middle_end_linear_run(struct draw_pt_middle_end *middle,
struct draw_fetch_info fetch_info;
struct draw_prim_info prim_info;
- fetch_info.linear = TRUE;
+ fetch_info.linear = true;
fetch_info.start = start;
fetch_info.count = count;
fetch_info.elts = NULL;
- prim_info.linear = TRUE;
+ prim_info.linear = true;
prim_info.start = start;
prim_info.count = count;
prim_info.elts = NULL;
@@ -841,11 +785,11 @@ llvm_middle_end_linear_run(struct draw_pt_middle_end *middle,
}
-static boolean
+static bool
llvm_middle_end_linear_run_elts(struct draw_pt_middle_end *middle,
unsigned start,
unsigned count,
- const ushort *draw_elts,
+ const uint16_t *draw_elts,
unsigned draw_count,
unsigned prim_flags)
{
@@ -853,12 +797,12 @@ llvm_middle_end_linear_run_elts(struct draw_pt_middle_end *middle,
struct draw_fetch_info fetch_info;
struct draw_prim_info prim_info;
- fetch_info.linear = TRUE;
+ fetch_info.linear = true;
fetch_info.start = start;
fetch_info.count = count;
fetch_info.elts = NULL;
- prim_info.linear = FALSE;
+ prim_info.linear = false;
prim_info.start = 0;
prim_info.count = draw_count;
prim_info.elts = draw_elts;
@@ -869,7 +813,7 @@ llvm_middle_end_linear_run_elts(struct draw_pt_middle_end *middle,
llvm_pipeline_generic(middle, &fetch_info, &prim_info);
- return TRUE;
+ return true;
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_vsplit.c b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_vsplit.c
index 86548b817..45a9f1573 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_vsplit.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_vsplit.c
@@ -23,6 +23,8 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include <stdbool.h>
+
#include "util/macros.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -38,26 +40,26 @@ struct vsplit_frontend {
struct draw_pt_front_end base;
struct draw_context *draw;
- enum pipe_prim_type prim;
+ enum mesa_prim prim;
struct draw_pt_middle_end *middle;
unsigned max_vertices;
- ushort segment_size;
+ uint16_t segment_size;
/* buffers for splitting */
unsigned fetch_elts[SEGMENT_SIZE];
- ushort draw_elts[SEGMENT_SIZE];
- ushort identity_draw_elts[SEGMENT_SIZE];
+ uint16_t draw_elts[SEGMENT_SIZE];
+ uint16_t identity_draw_elts[SEGMENT_SIZE];
struct {
/* map a fetch element to a draw element */
unsigned fetches[MAP_SIZE];
- ushort draws[MAP_SIZE];
- boolean has_max_fetch;
+ uint16_t draws[MAP_SIZE];
+ bool has_max_fetch;
- ushort num_fetch_elts;
- ushort num_draw_elts;
+ uint16_t num_fetch_elts;
+ uint16_t num_draw_elts;
} cache;
};
@@ -66,7 +68,7 @@ static void
vsplit_clear_cache(struct vsplit_frontend *vsplit)
{
memset(vsplit->cache.fetches, 0xff, sizeof(vsplit->cache.fetches));
- vsplit->cache.has_max_fetch = FALSE;
+ vsplit->cache.has_max_fetch = false;
vsplit->cache.num_fetch_elts = 0;
vsplit->cache.num_draw_elts = 0;
}
@@ -119,36 +121,36 @@ vsplit_get_base_idx(unsigned start, unsigned fetch)
static inline void
-vsplit_add_cache_ubyte(struct vsplit_frontend *vsplit, const ubyte *elts,
+vsplit_add_cache_uint8(struct vsplit_frontend *vsplit, const uint8_t *elts,
unsigned start, unsigned fetch, int elt_bias)
{
struct draw_context *draw = vsplit->draw;
unsigned elt_idx;
elt_idx = vsplit_get_base_idx(start, fetch);
elt_idx = (unsigned)((int)(DRAW_GET_IDX(elts, elt_idx)) + elt_bias);
- /* unlike the uint case this can only happen with elt_bias */
+ /* unlike the uint32_t case this can only happen with elt_bias */
if (elt_bias && elt_idx == DRAW_MAX_FETCH_IDX && !vsplit->cache.has_max_fetch) {
unsigned hash = elt_idx % MAP_SIZE;
vsplit->cache.fetches[hash] = 0;
- vsplit->cache.has_max_fetch = TRUE;
+ vsplit->cache.has_max_fetch = true;
}
vsplit_add_cache(vsplit, elt_idx);
}
static inline void
-vsplit_add_cache_ushort(struct vsplit_frontend *vsplit, const ushort *elts,
- unsigned start, unsigned fetch, int elt_bias)
+vsplit_add_cache_uint16(struct vsplit_frontend *vsplit, const uint16_t *elts,
+ unsigned start, unsigned fetch, int elt_bias)
{
struct draw_context *draw = vsplit->draw;
unsigned elt_idx;
elt_idx = vsplit_get_base_idx(start, fetch);
elt_idx = (unsigned)((int)(DRAW_GET_IDX(elts, elt_idx)) + elt_bias);
- /* unlike the uint case this can only happen with elt_bias */
+ /* unlike the uint32_t case this can only happen with elt_bias */
if (elt_bias && elt_idx == DRAW_MAX_FETCH_IDX && !vsplit->cache.has_max_fetch) {
unsigned hash = elt_idx % MAP_SIZE;
vsplit->cache.fetches[hash] = 0;
- vsplit->cache.has_max_fetch = TRUE;
+ vsplit->cache.has_max_fetch = true;
}
vsplit_add_cache(vsplit, elt_idx);
}
@@ -156,11 +158,11 @@ vsplit_add_cache_ushort(struct vsplit_frontend *vsplit, const ushort *elts,
/**
* Add a fetch element and add it to the draw elements. The fetch element is
- * in full range (uint).
+ * in full range (uint32_t).
*/
static inline void
-vsplit_add_cache_uint(struct vsplit_frontend *vsplit, const uint *elts,
- unsigned start, unsigned fetch, int elt_bias)
+vsplit_add_cache_uint32(struct vsplit_frontend *vsplit, const uint32_t *elts,
+ unsigned start, unsigned fetch, int elt_bias)
{
struct draw_context *draw = vsplit->draw;
unsigned elt_idx;
@@ -174,7 +176,7 @@ vsplit_add_cache_uint(struct vsplit_frontend *vsplit, const uint *elts,
unsigned hash = elt_idx % MAP_SIZE;
/* force update - any value will do except DRAW_MAX_FETCH_IDX */
vsplit->cache.fetches[hash] = 0;
- vsplit->cache.has_max_fetch = TRUE;
+ vsplit->cache.has_max_fetch = true;
}
vsplit_add_cache(vsplit, elt_idx);
}
@@ -183,25 +185,25 @@ vsplit_add_cache_uint(struct vsplit_frontend *vsplit, const uint *elts,
#define FUNC vsplit_run_linear
#include "draw_pt_vsplit_tmp.h"
-#define FUNC vsplit_run_ubyte
-#define ELT_TYPE ubyte
-#define ADD_CACHE(vsplit, ib, start, fetch, bias) vsplit_add_cache_ubyte(vsplit,ib,start,fetch,bias)
+#define FUNC vsplit_run_uint8
+#define ELT_TYPE uint8_t
+#define ADD_CACHE(vsplit, ib, start, fetch, bias) vsplit_add_cache_uint8(vsplit,ib,start,fetch,bias)
#include "draw_pt_vsplit_tmp.h"
-#define FUNC vsplit_run_ushort
-#define ELT_TYPE ushort
-#define ADD_CACHE(vsplit, ib, start, fetch, bias) vsplit_add_cache_ushort(vsplit,ib,start,fetch, bias)
+#define FUNC vsplit_run_uint16
+#define ELT_TYPE uint16_t
+#define ADD_CACHE(vsplit, ib, start, fetch, bias) vsplit_add_cache_uint16(vsplit,ib,start,fetch, bias)
#include "draw_pt_vsplit_tmp.h"
-#define FUNC vsplit_run_uint
-#define ELT_TYPE uint
-#define ADD_CACHE(vsplit, ib, start, fetch, bias) vsplit_add_cache_uint(vsplit, ib, start, fetch, bias)
+#define FUNC vsplit_run_uint32
+#define ELT_TYPE uint32_t
+#define ADD_CACHE(vsplit, ib, start, fetch, bias) vsplit_add_cache_uint32(vsplit, ib, start, fetch, bias)
#include "draw_pt_vsplit_tmp.h"
static void
vsplit_prepare(struct draw_pt_front_end *frontend,
- enum pipe_prim_type in_prim,
+ enum mesa_prim in_prim,
struct draw_pt_middle_end *middle,
unsigned opt)
{
@@ -212,13 +214,13 @@ vsplit_prepare(struct draw_pt_front_end *frontend,
vsplit->base.run = vsplit_run_linear;
break;
case 1:
- vsplit->base.run = vsplit_run_ubyte;
+ vsplit->base.run = vsplit_run_uint8;
break;
case 2:
- vsplit->base.run = vsplit_run_ushort;
+ vsplit->base.run = vsplit_run_uint16;
break;
case 4:
- vsplit->base.run = vsplit_run_uint;
+ vsplit->base.run = vsplit_run_uint32;
break;
default:
assert(0);
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_vsplit_tmp.h b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_vsplit_tmp.h
index 53fa51091..5440a2e1c 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_pt_vsplit_tmp.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_pt_vsplit_tmp.h
@@ -29,7 +29,7 @@
* Fetch all elements in [min_index, max_index] with bias, and use the
* (rebased) index buffer as the draw elements.
*/
-static boolean
+static bool
CONCAT2(vsplit_primitive_, ELT_TYPE)(struct vsplit_frontend *vsplit,
unsigned istart, unsigned icount)
{
@@ -39,7 +39,7 @@ CONCAT2(vsplit_primitive_, ELT_TYPE)(struct vsplit_frontend *vsplit,
const unsigned max_index = draw->pt.user.max_index;
const int elt_bias = draw->pt.user.eltBias;
unsigned fetch_start, fetch_count;
- const ushort *draw_elts = NULL;
+ const uint16_t *draw_elts = NULL;
const unsigned start = istart;
const unsigned end = istart + icount;
@@ -47,12 +47,12 @@ CONCAT2(vsplit_primitive_, ELT_TYPE)(struct vsplit_frontend *vsplit,
* through the normal paths */
if (end >= draw->pt.user.eltMax ||
end < istart)
- return FALSE;
+ return false;
/* use the ib directly */
if (min_index == 0 && sizeof(ib[0]) == sizeof(draw_elts[0])) {
if (icount > vsplit->max_vertices)
- return FALSE;
+ return false;
for (unsigned i = 0; i < icount; i++) {
ELT_TYPE idx = DRAW_GET_IDX(ib, start + i);
@@ -60,24 +60,24 @@ CONCAT2(vsplit_primitive_, ELT_TYPE)(struct vsplit_frontend *vsplit,
debug_printf("warning: index out of range\n");
}
}
- draw_elts = (const ushort *) (ib + istart);
+ draw_elts = (const uint16_t *) (ib + istart);
} else {
/* have to go through vsplit->draw_elts */
if (icount > vsplit->segment_size)
- return FALSE;
+ return false;
}
/* this is faster only when we fetch less elements than the normal path */
if (max_index - min_index > icount - 1)
- return FALSE;
+ return false;
if (elt_bias < 0 && (int) min_index < -elt_bias)
- return FALSE;
+ return false;
/* why this check? */
for (unsigned i = 0; i < draw->pt.nr_vertex_elements; i++) {
if (draw->pt.vertex_element[i].instance_divisor)
- return FALSE;
+ return false;
}
fetch_start = min_index + elt_bias;
@@ -85,7 +85,7 @@ CONCAT2(vsplit_primitive_, ELT_TYPE)(struct vsplit_frontend *vsplit,
/* Check for overflow in the fetch_start */
if (fetch_start < min_index || fetch_start < elt_bias)
- return FALSE;
+ return false;
if (!draw_elts) {
if (min_index == 0) {
@@ -95,7 +95,7 @@ CONCAT2(vsplit_primitive_, ELT_TYPE)(struct vsplit_frontend *vsplit,
if (idx < min_index || idx > max_index) {
debug_printf("warning: index out of range\n");
}
- vsplit->draw_elts[i] = (ushort) idx;
+ vsplit->draw_elts[i] = (uint16_t) idx;
}
} else {
for (unsigned i = 0; i < icount; i++) {
@@ -104,7 +104,7 @@ CONCAT2(vsplit_primitive_, ELT_TYPE)(struct vsplit_frontend *vsplit,
if (idx < min_index || idx > max_index) {
debug_printf("warning: index out of range\n");
}
- vsplit->draw_elts[i] = (ushort) (idx - min_index);
+ vsplit->draw_elts[i] = (uint16_t) (idx - min_index);
}
}
@@ -127,8 +127,8 @@ static inline void
CONCAT2(vsplit_segment_cache_, ELT_TYPE)(struct vsplit_frontend *vsplit,
unsigned flags,
unsigned istart, unsigned icount,
- boolean spoken, unsigned ispoken,
- boolean close, unsigned iclose)
+ bool spoken, unsigned ispoken,
+ bool close, unsigned iclose)
{
struct draw_context *draw = vsplit->draw;
const ELT_TYPE *ib = (const ELT_TYPE *) draw->pt.user.elts;
@@ -171,7 +171,7 @@ CONCAT2(vsplit_segment_simple_, ELT_TYPE)(struct vsplit_frontend *vsplit,
unsigned icount)
{
CONCAT2(vsplit_segment_cache_, ELT_TYPE)(vsplit,
- flags, istart, icount, FALSE, 0, FALSE, 0);
+ flags, istart, icount, false, 0, false, 0);
}
@@ -182,10 +182,10 @@ CONCAT2(vsplit_segment_loop_, ELT_TYPE)(struct vsplit_frontend *vsplit,
unsigned icount,
unsigned i0)
{
- const boolean close_loop = ((flags) == DRAW_SPLIT_BEFORE);
+ const bool close_loop = ((flags) == DRAW_SPLIT_BEFORE);
CONCAT2(vsplit_segment_cache_, ELT_TYPE)(vsplit,
- flags, istart, icount, FALSE, 0, close_loop, i0);
+ flags, istart, icount, false, 0, close_loop, i0);
}
@@ -196,16 +196,16 @@ CONCAT2(vsplit_segment_fan_, ELT_TYPE)(struct vsplit_frontend *vsplit,
unsigned icount,
unsigned i0)
{
- const boolean use_spoken = (((flags) & DRAW_SPLIT_BEFORE) != 0);
+ const bool use_spoken = (((flags) & DRAW_SPLIT_BEFORE) != 0);
CONCAT2(vsplit_segment_cache_, ELT_TYPE)(vsplit,
- flags, istart, icount, use_spoken, i0, FALSE, 0);
+ flags, istart, icount, use_spoken, i0, false, 0);
}
#define LOCAL_VARS \
struct vsplit_frontend *vsplit = (struct vsplit_frontend *) frontend; \
- const enum pipe_prim_type prim = vsplit->prim; \
+ const enum mesa_prim prim = vsplit->prim; \
const unsigned max_count_simple = vsplit->segment_size; \
const unsigned max_count_loop = vsplit->segment_size - 1; \
const unsigned max_count_fan = vsplit->segment_size;
@@ -228,7 +228,7 @@ static void
vsplit_segment_loop_linear(struct vsplit_frontend *vsplit, unsigned flags,
unsigned istart, unsigned icount, unsigned i0)
{
- boolean close_loop = (flags == DRAW_SPLIT_BEFORE);
+ bool close_loop = (flags == DRAW_SPLIT_BEFORE);
unsigned nr;
assert(icount + !!close_loop <= vsplit->segment_size);
@@ -253,7 +253,7 @@ static void
vsplit_segment_fan_linear(struct vsplit_frontend *vsplit, unsigned flags,
unsigned istart, unsigned icount, unsigned i0)
{
- boolean use_spoken = ((flags & DRAW_SPLIT_BEFORE) != 0);
+ bool use_spoken = ((flags & DRAW_SPLIT_BEFORE) != 0);
unsigned nr = 0;
assert(icount <= vsplit->segment_size);
@@ -274,12 +274,12 @@ vsplit_segment_fan_linear(struct vsplit_frontend *vsplit, unsigned flags,
#define LOCAL_VARS \
struct vsplit_frontend *vsplit = (struct vsplit_frontend *) frontend; \
- const enum pipe_prim_type prim = vsplit->prim; \
+ const enum mesa_prim prim = vsplit->prim; \
const unsigned max_count_simple = vsplit->max_vertices; \
const unsigned max_count_loop = vsplit->segment_size - 1; \
const unsigned max_count_fan = vsplit->segment_size;
-#define PRIMITIVE(istart, icount) FALSE
+#define PRIMITIVE(istart, icount) false
#define ELT_TYPE linear
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_so_emit_tmp.h b/lib/mesa/src/gallium/auxiliary/draw/draw_so_emit_tmp.h
index 101c7eea7..8abda74e8 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_so_emit_tmp.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_so_emit_tmp.h
@@ -7,17 +7,17 @@
#define FUNC_ENTER \
/* declare more local vars */ \
- const enum pipe_prim_type prim = input_prims->prim; \
+ const enum mesa_prim prim = input_prims->prim; \
const unsigned prim_flags = input_prims->flags; \
- const boolean quads_flatshade_last = FALSE; \
- const boolean last_vertex_last = !so->draw->rasterizer->flatshade_first; \
+ const bool quads_flatshade_last = false; \
+ const bool last_vertex_last = !so->draw->rasterizer->flatshade_first; \
do { \
switch (prim) { \
- case PIPE_PRIM_LINES_ADJACENCY: \
- case PIPE_PRIM_LINE_STRIP_ADJACENCY: \
- case PIPE_PRIM_TRIANGLES_ADJACENCY: \
- case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY: \
- assert(!"unexpected primitive type in stream output"); \
+ case MESA_PRIM_LINES_ADJACENCY: \
+ case MESA_PRIM_LINE_STRIP_ADJACENCY: \
+ case MESA_PRIM_TRIANGLES_ADJACENCY: \
+ case MESA_PRIM_TRIANGLE_STRIP_ADJACENCY: \
+ assert(!"unexpected primitive type in stream output"); \
return; \
default: \
break; \
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_tess.c b/lib/mesa/src/gallium/auxiliary/draw/draw_tess.c
index 4240b48e5..3a0eb3c1e 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_tess.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_tess.c
@@ -39,8 +39,8 @@ draw_tes_get_input_index(int semantic, int index,
const struct tgsi_shader_info *input_info)
{
int i;
- const ubyte *input_semantic_names = input_info->output_semantic_name;
- const ubyte *input_semantic_indices = input_info->output_semantic_index;
+ const uint8_t *input_semantic_names = input_info->output_semantic_name;
+ const uint8_t *input_semantic_indices = input_info->output_semantic_index;
for (i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
if (input_semantic_names[i] == semantic &&
input_semantic_indices[i] == index)
@@ -66,7 +66,7 @@ llvm_fetch_tcs_input(struct draw_tess_ctrl_shader *shader,
for (i = 0; i < num_vertices; i++) {
const float (*input)[4];
int vertex_idx = prim_id * num_vertices + i;
- if (input_prim_info->linear == FALSE)
+ if (input_prim_info->linear == false)
vertex_idx = input_prim_info->elts[vertex_idx];
#if DEBUG_INPUTS
debug_printf("%d) tcs vertex index = %d (prim idx = %d)\n",
@@ -145,7 +145,8 @@ llvm_store_tcs_output(struct draw_tess_ctrl_shader *shader,
static void
llvm_tcs_run(struct draw_tess_ctrl_shader *shader, uint32_t prim_id)
{
- shader->current_variant->jit_func(shader->jit_context, shader->tcs_input->data, shader->tcs_output->data, prim_id,
+ shader->current_variant->jit_func(shader->jit_resources,
+ shader->tcs_input->data, shader->tcs_output->data, prim_id,
shader->draw->pt.vertices_per_patch, shader->draw->pt.user.viewid);
}
#endif
@@ -154,8 +155,6 @@ llvm_tcs_run(struct draw_tess_ctrl_shader *shader, uint32_t prim_id)
* Execute tess ctrl shader.
*/
int draw_tess_ctrl_shader_run(struct draw_tess_ctrl_shader *shader,
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
const struct draw_vertex_info *input_verts,
const struct draw_prim_info *input_prim,
const struct tgsi_shader_info *input_info,
@@ -176,11 +175,11 @@ int draw_tess_ctrl_shader_run(struct draw_tess_ctrl_shader *shader,
shader->input_vertex_stride = input_stride;
shader->input_info = input_info;
- output_prims->linear = TRUE;
+ output_prims->linear = true;
output_prims->start = 0;
output_prims->elts = NULL;
output_prims->count = 0;
- output_prims->prim = PIPE_PRIM_PATCHES;
+ output_prims->prim = MESA_PRIM_PATCHES;
output_prims->flags = 0;
output_prims->primitive_lengths = NULL;
output_prims->primitive_count = 0;
@@ -232,7 +231,7 @@ llvm_fetch_tes_input(struct draw_tess_eval_shader *shader,
const float (*input)[4];
int vertex_idx = prim_id * num_vertices + i;
- if (input_prim_info->linear == FALSE)
+ if (input_prim_info->linear == false)
vertex_idx = input_prim_info->elts[vertex_idx];
#if DEBUG_INPUTS
debug_printf("%d) tes vertex index = %d (prim idx = %d)\n",
@@ -308,7 +307,8 @@ llvm_tes_run(struct draw_tess_eval_shader *shader,
struct pipe_tessellation_factors *tess_factors,
struct vertex_header *output)
{
- shader->current_variant->jit_func(shader->jit_context, shader->tes_input->data, output, prim_id,
+ shader->current_variant->jit_func(shader->jit_resources,
+ shader->tes_input->data, output, prim_id,
tess_data->num_domain_points, tess_data->domain_points_u, tess_data->domain_points_v,
tess_factors->outer_tf, tess_factors->inner_tf, patch_vertices_in,
shader->draw->pt.user.viewid);
@@ -319,27 +319,25 @@ llvm_tes_run(struct draw_tess_eval_shader *shader,
* Execute tess eval shader.
*/
int draw_tess_eval_shader_run(struct draw_tess_eval_shader *shader,
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
unsigned num_input_vertices_per_patch,
const struct draw_vertex_info *input_verts,
const struct draw_prim_info *input_prim,
const struct tgsi_shader_info *input_info,
struct draw_vertex_info *output_verts,
struct draw_prim_info *output_prims,
- ushort **elts_out)
+ uint16_t **elts_out)
{
const float (*input)[4] = (const float (*)[4])input_verts->verts->data;
unsigned num_outputs = draw_total_tes_outputs(shader->draw);
unsigned input_stride = input_verts->vertex_size;
unsigned vertex_size = sizeof(struct vertex_header) + num_outputs * 4 * sizeof(float);
- ushort *elts = NULL;
+ uint16_t *elts = NULL;
output_verts->vertex_size = vertex_size;
output_verts->stride = output_verts->vertex_size;
output_verts->count = 0;
output_verts->verts = NULL;
- output_prims->linear = FALSE;
+ output_prims->linear = false;
output_prims->start = 0;
output_prims->elts = NULL;
output_prims->count = 0;
@@ -418,7 +416,7 @@ draw_create_tess_ctrl_shader(struct draw_context *draw,
const struct pipe_shader_state *state)
{
#ifdef DRAW_LLVM_AVAILABLE
- boolean use_llvm = draw->llvm != NULL;
+ bool use_llvm = draw->llvm != NULL;
struct llvm_tess_ctrl_shader *llvm_tcs = NULL;
#endif
struct draw_tess_ctrl_shader *tcs;
@@ -458,7 +456,7 @@ draw_create_tess_ctrl_shader(struct draw_context *draw,
tcs->tcs_output = align_malloc(sizeof(struct draw_tcs_outputs), 16);
memset(tcs->tcs_output, 0, sizeof(struct draw_tcs_outputs));
- tcs->jit_context = &draw->llvm->tcs_jit_context;
+ tcs->jit_resources = &draw->llvm->jit_resources[PIPE_SHADER_TESS_CTRL];
llvm_tcs->variant_key_size =
draw_tcs_llvm_variant_key_size(
tcs->info.file_max[TGSI_FILE_SAMPLER]+1,
@@ -520,7 +518,7 @@ draw_create_tess_eval_shader(struct draw_context *draw,
const struct pipe_shader_state *state)
{
#ifdef DRAW_LLVM_AVAILABLE
- boolean use_llvm = draw->llvm != NULL;
+ bool use_llvm = draw->llvm != NULL;
struct llvm_tess_eval_shader *llvm_tes = NULL;
#endif
struct draw_tess_eval_shader *tes;
@@ -583,7 +581,7 @@ draw_create_tess_eval_shader(struct draw_context *draw,
tes->tes_input = align_malloc(sizeof(struct draw_tes_inputs), 16);
memset(tes->tes_input, 0, sizeof(struct draw_tes_inputs));
- tes->jit_context = &draw->llvm->tes_jit_context;
+ tes->jit_resources = &draw->llvm->jit_resources[PIPE_SHADER_TESS_EVAL];
llvm_tes->variant_key_size =
draw_tes_llvm_variant_key_size(
tes->info.file_max[TGSI_FILE_SAMPLER]+1,
@@ -640,12 +638,12 @@ void draw_tes_set_current_variant(struct draw_tess_eval_shader *shader,
}
#endif
-enum pipe_prim_type get_tes_output_prim(struct draw_tess_eval_shader *shader)
+enum mesa_prim get_tes_output_prim(struct draw_tess_eval_shader *shader)
{
if (shader->point_mode)
- return PIPE_PRIM_POINTS;
- else if (shader->prim_mode == PIPE_PRIM_LINES)
- return PIPE_PRIM_LINES;
+ return MESA_PRIM_POINTS;
+ else if (shader->prim_mode == MESA_PRIM_LINES)
+ return MESA_PRIM_LINES;
else
- return PIPE_PRIM_TRIANGLES;
+ return MESA_PRIM_TRIANGLES;
}
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_tess.h b/lib/mesa/src/gallium/auxiliary/draw/draw_tess.h
index 9a083f905..af79f81c2 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_tess.h
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_tess.h
@@ -29,6 +29,8 @@
#include "draw_context.h"
#include "draw_private.h"
+#include "tgsi/tgsi_scan.h"
+
struct draw_context;
#ifdef DRAW_LLVM_AVAILABLE
@@ -67,7 +69,7 @@ struct draw_tess_ctrl_shader {
#ifdef DRAW_LLVM_AVAILABLE
struct draw_tcs_inputs *tcs_input;
struct draw_tcs_outputs *tcs_output;
- struct draw_tcs_jit_context *jit_context;
+ struct lp_jit_resources *jit_resources;
struct draw_tcs_llvm_variant *current_variant;
#endif
};
@@ -77,7 +79,7 @@ struct draw_tess_eval_shader {
struct pipe_shader_state state;
struct tgsi_shader_info info;
- enum pipe_prim_type prim_mode;
+ enum mesa_prim prim_mode;
unsigned spacing;
unsigned vertex_order_cw;
unsigned point_mode;
@@ -94,16 +96,14 @@ struct draw_tess_eval_shader {
#ifdef DRAW_LLVM_AVAILABLE
struct draw_tes_inputs *tes_input;
- struct draw_tes_jit_context *jit_context;
+ struct lp_jit_resources *jit_resources;
struct draw_tes_llvm_variant *current_variant;
#endif
};
-enum pipe_prim_type get_tes_output_prim(struct draw_tess_eval_shader *shader);
+enum mesa_prim get_tes_output_prim(struct draw_tess_eval_shader *shader);
int draw_tess_ctrl_shader_run(struct draw_tess_ctrl_shader *shader,
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
const struct draw_vertex_info *input_verts,
const struct draw_prim_info *input_prim,
const struct tgsi_shader_info *input_info,
@@ -111,15 +111,13 @@ int draw_tess_ctrl_shader_run(struct draw_tess_ctrl_shader *shader,
struct draw_prim_info *output_prims );
int draw_tess_eval_shader_run(struct draw_tess_eval_shader *shader,
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],
unsigned num_input_vertices_per_patch,
const struct draw_vertex_info *input_verts,
const struct draw_prim_info *input_prim,
const struct tgsi_shader_info *input_info,
struct draw_vertex_info *output_verts,
struct draw_prim_info *output_prims,
- ushort **elts_out);
+ uint16_t **elts_out);
#ifdef DRAW_LLVM_AVAILABLE
void draw_tcs_set_current_variant(struct draw_tess_ctrl_shader *shader,
diff --git a/lib/mesa/src/gallium/auxiliary/draw/draw_vs_exec.c b/lib/mesa/src/gallium/auxiliary/draw/draw_vs_exec.c
index 5476f40c9..b56283cde 100644
--- a/lib/mesa/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/lib/mesa/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -92,8 +92,7 @@ static void
vs_exec_run_linear(struct draw_vertex_shader *shader,
const float (*input)[4],
float (*output)[4],
- const void *constants[PIPE_MAX_CONSTANT_BUFFERS],
- const unsigned const_size[PIPE_MAX_CONSTANT_BUFFERS],
+ const struct draw_buffer_info *constants,
unsigned count,
unsigned input_stride,
unsigned output_stride,
@@ -103,11 +102,11 @@ vs_exec_run_linear(struct draw_vertex_shader *shader,
struct tgsi_exec_machine *machine = evs->machine;
unsigned int i, j;
unsigned slot;
- boolean clamp_vertex_color = shader->draw->rasterizer->clamp_vertex_color;
+ bool clamp_vertex_color = shader->draw->rasterizer->clamp_vertex_color;
assert(!shader->draw->llvm);
tgsi_exec_set_constant_buffers(machine, PIPE_MAX_CONSTANT_BUFFERS,
- constants, const_size);
+ (const struct tgsi_exec_consts_info *)constants);
if (shader->info.uses_instanceid) {
unsigned i = machine->SysSemanticToIndex[TGSI_SEMANTIC_INSTANCEID];