aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/gallium/auxiliary')
-rw-r--r--mesalib/src/gallium/auxiliary/Android.mk11
-rw-r--r--mesalib/src/gallium/auxiliary/hud/hud_context.c6
-rw-r--r--mesalib/src/gallium/auxiliary/nir/tgsi_to_nir.c3
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blit.c6
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.c27
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_blitter.h16
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_dump_state.c2
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_format_etc.c3
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h20
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_tests.h8
10 files changed, 96 insertions, 6 deletions
diff --git a/mesalib/src/gallium/auxiliary/Android.mk b/mesalib/src/gallium/auxiliary/Android.mk
index 96a2125de..86430eb6a 100644
--- a/mesalib/src/gallium/auxiliary/Android.mk
+++ b/mesalib/src/gallium/auxiliary/Android.mk
@@ -30,12 +30,23 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
$(C_SOURCES) \
+ $(NIR_SOURCES) \
$(VL_STUB_SOURCES)
LOCAL_C_INCLUDES := \
$(GALLIUM_TOP)/auxiliary/util
+ifeq ($(MESA_ENABLE_LLVM),true)
+LOCAL_SRC_FILES += \
+ $(GALLIVM_SOURCES) \
+ $(GALLIVM_CPP_SOURCES)
+
+LOCAL_CPPFLAGS := -std=c++11
+endif
+
+# We need libmesa_glsl to get NIR's generated include directories.
LOCAL_MODULE := libmesa_gallium
+LOCAL_STATIC_LIBRARIES += libmesa_glsl
# generate sources
LOCAL_MODULE_CLASS := STATIC_LIBRARIES
diff --git a/mesalib/src/gallium/auxiliary/hud/hud_context.c b/mesalib/src/gallium/auxiliary/hud/hud_context.c
index 00ec20589..6a124f7d7 100644
--- a/mesalib/src/gallium/auxiliary/hud/hud_context.c
+++ b/mesalib/src/gallium/auxiliary/hud/hud_context.c
@@ -423,6 +423,8 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
cso_save_viewport(cso);
cso_save_stream_outputs(cso);
cso_save_geometry_shader(cso);
+ cso_save_tessctrl_shader(cso);
+ cso_save_tesseval_shader(cso);
cso_save_vertex_shader(cso);
cso_save_vertex_elements(cso);
cso_save_aux_vertex_buffer_slot(cso);
@@ -456,6 +458,8 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
cso_set_rasterizer(cso, &hud->rasterizer);
cso_set_viewport(cso, &viewport);
cso_set_stream_outputs(cso, 0, NULL, NULL);
+ cso_set_tessctrl_shader_handle(cso, NULL);
+ cso_set_tesseval_shader_handle(cso, NULL);
cso_set_geometry_shader_handle(cso, NULL);
cso_set_vertex_shader_handle(cso, hud->vs);
cso_set_vertex_elements(cso, 2, hud->velems);
@@ -548,6 +552,8 @@ hud_draw(struct hud_context *hud, struct pipe_resource *tex)
cso_restore_rasterizer(cso);
cso_restore_viewport(cso);
cso_restore_stream_outputs(cso);
+ cso_restore_tessctrl_shader(cso);
+ cso_restore_tesseval_shader(cso);
cso_restore_geometry_shader(cso);
cso_restore_vertex_shader(cso);
cso_restore_vertex_elements(cso);
diff --git a/mesalib/src/gallium/auxiliary/nir/tgsi_to_nir.c b/mesalib/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 59aaf6778..1702b4139 100644
--- a/mesalib/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/mesalib/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -401,7 +401,6 @@ ttn_src_for_file_and_index(struct ttn_compile *c, unsigned file, unsigned index,
load->num_components = 4;
load->const_index[0] = index;
- load->const_index[1] = 1;
if (dim) {
if (dimind) {
load->src[srcn] =
@@ -1625,7 +1624,6 @@ ttn_emit_instruction(struct ttn_compile *c)
}
if (tgsi_inst->Instruction.Saturate) {
- assert(tgsi_inst->Instruction.Saturate == TGSI_SAT_ZERO_ONE);
assert(!dest.dest.is_ssa);
ttn_move_dest(b, dest, nir_fsat(b, ttn_src_for_dest(b, &dest)));
}
@@ -1672,7 +1670,6 @@ ttn_add_output_stores(struct ttn_compile *c)
nir_intrinsic_instr_create(b->shader, nir_intrinsic_store_output);
store->num_components = 4;
store->const_index[0] = var->data.driver_location + i;
- store->const_index[1] = 1;
store->src[0].reg.reg = c->output_regs[var->data.driver_location].reg;
nir_instr_insert_after_cf_list(b->cf_node_list, &store->instr);
}
diff --git a/mesalib/src/gallium/auxiliary/util/u_blit.c b/mesalib/src/gallium/auxiliary/util/u_blit.c
index 90408ffdc..3f3b5fe63 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blit.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blit.c
@@ -535,6 +535,8 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_save_framebuffer(ctx->cso);
cso_save_fragment_shader(ctx->cso);
cso_save_vertex_shader(ctx->cso);
+ cso_save_tessctrl_shader(ctx->cso);
+ cso_save_tesseval_shader(ctx->cso);
cso_save_geometry_shader(ctx->cso);
cso_save_vertex_elements(ctx->cso);
cso_save_aux_vertex_buffer_slot(ctx->cso);
@@ -571,6 +573,8 @@ util_blit_pixels_tex(struct blit_state *ctx,
set_fragment_shader(ctx, TGSI_WRITEMASK_XYZW,
src_sampler_view->texture->target);
set_vertex_shader(ctx);
+ cso_set_tessctrl_shader_handle(ctx->cso, NULL);
+ cso_set_tesseval_shader_handle(ctx->cso, NULL);
cso_set_geometry_shader_handle(ctx->cso, NULL);
/* drawing dest */
@@ -611,6 +615,8 @@ util_blit_pixels_tex(struct blit_state *ctx,
cso_restore_framebuffer(ctx->cso);
cso_restore_fragment_shader(ctx->cso);
cso_restore_vertex_shader(ctx->cso);
+ cso_restore_tessctrl_shader(ctx->cso);
+ cso_restore_tesseval_shader(ctx->cso);
cso_restore_geometry_shader(ctx->cso);
cso_restore_vertex_elements(ctx->cso);
cso_restore_aux_vertex_buffer_slot(ctx->cso);
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.c b/mesalib/src/gallium/auxiliary/util/u_blitter.c
index 24a5b93e1..16bf90fc9 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.c
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.c
@@ -130,6 +130,7 @@ struct blitter_context_priv
unsigned dst_height;
boolean has_geometry_shader;
+ boolean has_tessellation;
boolean has_layered;
boolean has_stream_out;
boolean has_stencil_export;
@@ -183,6 +184,11 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
ctx->has_geometry_shader =
pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_GEOMETRY,
PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0;
+
+ ctx->has_tessellation =
+ pipe->screen->get_shader_param(pipe->screen, PIPE_SHADER_TESS_CTRL,
+ PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0;
+
ctx->has_stream_out =
pipe->screen->get_param(pipe->screen,
PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS) != 0;
@@ -510,6 +516,8 @@ static void blitter_check_saved_vertex_states(struct blitter_context_priv *ctx)
assert(ctx->base.saved_velem_state != INVALID_PTR);
assert(ctx->base.saved_vs != INVALID_PTR);
assert(!ctx->has_geometry_shader || ctx->base.saved_gs != INVALID_PTR);
+ assert(!ctx->has_tessellation || ctx->base.saved_tcs != INVALID_PTR);
+ assert(!ctx->has_tessellation || ctx->base.saved_tes != INVALID_PTR);
assert(!ctx->has_stream_out || ctx->base.saved_num_so_targets != ~0);
assert(ctx->base.saved_rs_state != INVALID_PTR);
}
@@ -538,6 +546,13 @@ static void blitter_restore_vertex_states(struct blitter_context_priv *ctx)
ctx->base.saved_gs = INVALID_PTR;
}
+ if (ctx->has_tessellation) {
+ pipe->bind_tcs_state(pipe, ctx->base.saved_tcs);
+ pipe->bind_tes_state(pipe, ctx->base.saved_tes);
+ ctx->base.saved_tcs = INVALID_PTR;
+ ctx->base.saved_tes = INVALID_PTR;
+ }
+
/* Stream outputs. */
if (ctx->has_stream_out) {
unsigned offsets[PIPE_MAX_SO_BUFFERS];
@@ -1108,6 +1123,10 @@ static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx,
if (ctx->has_geometry_shader)
pipe->bind_gs_state(pipe, NULL);
+ if (ctx->has_tessellation) {
+ pipe->bind_tcs_state(pipe, NULL);
+ pipe->bind_tes_state(pipe, NULL);
+ }
if (ctx->has_stream_out)
pipe->set_stream_output_targets(pipe, 0, NULL, NULL);
}
@@ -1967,6 +1986,10 @@ void util_blitter_copy_buffer(struct blitter_context *blitter,
bind_vs_pos_only(ctx);
if (ctx->has_geometry_shader)
pipe->bind_gs_state(pipe, NULL);
+ if (ctx->has_tessellation) {
+ pipe->bind_tcs_state(pipe, NULL);
+ pipe->bind_tes_state(pipe, NULL);
+ }
pipe->bind_rasterizer_state(pipe, ctx->rs_discard_state);
so_target = pipe->create_stream_output_target(pipe, dst, dstx, size);
@@ -2027,6 +2050,10 @@ void util_blitter_clear_buffer(struct blitter_context *blitter,
bind_vs_pos_only(ctx);
if (ctx->has_geometry_shader)
pipe->bind_gs_state(pipe, NULL);
+ if (ctx->has_tessellation) {
+ pipe->bind_tcs_state(pipe, NULL);
+ pipe->bind_tes_state(pipe, NULL);
+ }
pipe->bind_rasterizer_state(pipe, ctx->rs_discard_state);
so_target = pipe->create_stream_output_target(pipe, dst, offset, size);
diff --git a/mesalib/src/gallium/auxiliary/util/u_blitter.h b/mesalib/src/gallium/auxiliary/util/u_blitter.h
index 1568030ac..93b0e513b 100644
--- a/mesalib/src/gallium/auxiliary/util/u_blitter.h
+++ b/mesalib/src/gallium/auxiliary/util/u_blitter.h
@@ -102,7 +102,7 @@ struct blitter_context
void *saved_dsa_state; /**< depth stencil alpha state */
void *saved_velem_state; /**< vertex elements state */
void *saved_rs_state; /**< rasterizer state */
- void *saved_fs, *saved_vs, *saved_gs; /**< shaders */
+ void *saved_fs, *saved_vs, *saved_gs, *saved_tcs, *saved_tes; /**< shaders */
struct pipe_framebuffer_state saved_fb_state; /**< framebuffer state */
struct pipe_stencil_ref saved_stencil_ref; /**< stencil ref */
@@ -427,6 +427,20 @@ void util_blitter_save_geometry_shader(struct blitter_context *blitter,
blitter->saved_gs = gs;
}
+static INLINE void
+util_blitter_save_tessctrl_shader(struct blitter_context *blitter,
+ void *sh)
+{
+ blitter->saved_tcs = sh;
+}
+
+static INLINE void
+util_blitter_save_tesseval_shader(struct blitter_context *blitter,
+ void *sh)
+{
+ blitter->saved_tes = sh;
+}
+
static INLINE
void util_blitter_save_framebuffer(struct blitter_context *blitter,
const struct pipe_framebuffer_state *state)
diff --git a/mesalib/src/gallium/auxiliary/util/u_dump_state.c b/mesalib/src/gallium/auxiliary/util/u_dump_state.c
index e6614d5d2..7f620b50c 100644
--- a/mesalib/src/gallium/auxiliary/util/u_dump_state.c
+++ b/mesalib/src/gallium/auxiliary/util/u_dump_state.c
@@ -750,6 +750,8 @@ util_dump_draw_info(FILE *stream, const struct pipe_draw_info *state)
util_dump_member(stream, uint, state, start_instance);
util_dump_member(stream, uint, state, instance_count);
+ util_dump_member(stream, uint, state, vertices_per_patch);
+
util_dump_member(stream, int, state, index_bias);
util_dump_member(stream, uint, state, min_index);
util_dump_member(stream, uint, state, max_index);
diff --git a/mesalib/src/gallium/auxiliary/util/u_format_etc.c b/mesalib/src/gallium/auxiliary/util/u_format_etc.c
index f909b1608..63e03ff5c 100644
--- a/mesalib/src/gallium/auxiliary/util/u_format_etc.c
+++ b/mesalib/src/gallium/auxiliary/util/u_format_etc.c
@@ -65,11 +65,10 @@ util_format_etc1_rgb8_pack_rgba_float(uint8_t *dst_row, unsigned dst_stride, con
void
util_format_etc1_rgb8_fetch_rgba_float(float *dst, const uint8_t *src, unsigned i, unsigned j)
{
- const unsigned bw = 4, bh = 4;
struct etc1_block block;
uint8_t tmp[3];
- assert(i < bw && j < bh);
+ assert(i < 4 && j < 4); /* check i, j against 4x4 block size */
etc1_parse_block(&block, src);
etc1_fetch_texel(&block, i, j, tmp);
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index 3d27a59e8..3b4040f0e 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -42,6 +42,7 @@
#include "pipe/p_compiler.h"
#include "c99_math.h"
+#include <assert.h>
#include <float.h>
#include <stdarg.h>
@@ -424,6 +425,25 @@ util_last_bit(unsigned u)
}
/**
+ * Find last bit set in a word. The least significant bit is 1.
+ * Return 0 if no bits are set.
+ */
+static INLINE unsigned
+util_last_bit64(uint64_t u)
+{
+#if defined(HAVE___BUILTIN_CLZLL)
+ return u == 0 ? 0 : 64 - __builtin_clzll(u);
+#else
+ unsigned r = 0;
+ while (u) {
+ r++;
+ u >>= 1;
+ }
+ return r;
+#endif
+}
+
+/**
* Find last bit in a word that does not match the sign bit. The least
* significant bit is 1.
* Return 0 if no bits are set.
diff --git a/mesalib/src/gallium/auxiliary/util/u_tests.h b/mesalib/src/gallium/auxiliary/util/u_tests.h
index 49ae54f87..106b0a0a9 100644
--- a/mesalib/src/gallium/auxiliary/util/u_tests.h
+++ b/mesalib/src/gallium/auxiliary/util/u_tests.h
@@ -30,8 +30,16 @@
#include "pipe/p_compiler.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+
struct pipe_screen;
void util_run_tests(struct pipe_screen *screen);
+#ifdef __cplusplus
+}
+#endif
+
#endif