summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/softpipe
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2021-07-22 10:50:50 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2021-07-22 10:50:50 +0000
commit9130ec005fbc78a62420643414d8354d0929ca50 (patch)
tree6762777acdd2d4eee17ef87290e80dc7afe2b73d /lib/mesa/src/gallium/drivers/softpipe
parentca11beabae33eb59fb981b8adf50b1d47a2a98f0 (diff)
Merge Mesa 21.1.5
Diffstat (limited to 'lib/mesa/src/gallium/drivers/softpipe')
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/SConscript14
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_compute.c7
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_context.c22
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_context.h7
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_draw_arrays.c19
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_screen.c165
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_state_derived.c4
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c13
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_state_shader.c122
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_state_vertex.c9
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_tex_sample.c22
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_tex_sample.h2
-rw-r--r--lib/mesa/src/gallium/drivers/softpipe/sp_texture.c12
13 files changed, 230 insertions, 188 deletions
diff --git a/lib/mesa/src/gallium/drivers/softpipe/SConscript b/lib/mesa/src/gallium/drivers/softpipe/SConscript
deleted file mode 100644
index dc3542c51..000000000
--- a/lib/mesa/src/gallium/drivers/softpipe/SConscript
+++ /dev/null
@@ -1,14 +0,0 @@
-Import('*')
-
-env = env.Clone()
-
-env.MSVC2008Compat()
-
-softpipe = env.ConvenienceLibrary(
- target = 'softpipe',
- source = env.ParseSourceList('Makefile.sources', 'C_SOURCES')
- )
-
-env.Alias('softpipe', softpipe)
-
-Export('softpipe')
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_compute.c b/lib/mesa/src/gallium/drivers/softpipe/sp_compute.c
index 31252255b..ac8d51196 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_compute.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_compute.c
@@ -152,7 +152,7 @@ fill_grid_size(struct pipe_context *context,
params = pipe_buffer_map_range(context, info->indirect,
info->indirect_offset,
3 * sizeof(uint32_t),
- PIPE_TRANSFER_READ,
+ PIPE_MAP_READ,
&transfer);
if (!transfer)
@@ -227,6 +227,11 @@ softpipe_launch_grid(struct pipe_context *context,
}
}
+ if (softpipe->active_statistics_queries) {
+ softpipe->pipeline_statistics.cs_invocations +=
+ grid_size[0] * grid_size[1] * grid_size[2];
+ }
+
for (i = 0; i < num_threads_in_group; i++) {
cs_delete(cs, machines[i]);
tgsi_exec_machine_destroy(machines[i]);
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_context.c b/lib/mesa/src/gallium/drivers/softpipe/sp_context.c
index ed0e67829..a633a43a4 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_context.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_context.c
@@ -191,6 +191,18 @@ softpipe_render_condition(struct pipe_context *pipe,
}
+static void
+softpipe_set_debug_callback(struct pipe_context *pipe,
+ const struct pipe_debug_callback *cb)
+{
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+
+ if (cb)
+ softpipe->debug = *cb;
+ else
+ memset(&softpipe->debug, 0, sizeof(softpipe->debug));
+}
+
struct pipe_context *
softpipe_create_context(struct pipe_screen *screen,
@@ -214,10 +226,6 @@ softpipe_create_context(struct pipe_screen *screen,
softpipe->tgsi.buffer[i] = sp_create_tgsi_buffer();
}
- softpipe->dump_fs = debug_get_bool_option( "SOFTPIPE_DUMP_FS", false );
- softpipe->dump_gs = debug_get_bool_option( "SOFTPIPE_DUMP_GS", false );
- softpipe->dump_cs = debug_get_bool_option( "SOFTPIPE_DUMP_CS", false );
-
softpipe->pipe.screen = screen;
softpipe->pipe.destroy = softpipe_destroy;
softpipe->pipe.priv = priv;
@@ -235,6 +243,7 @@ softpipe_create_context(struct pipe_screen *screen,
softpipe_init_image_funcs(&softpipe->pipe);
softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
+ softpipe->pipe.set_debug_callback = softpipe_set_debug_callback;
softpipe->pipe.draw_vbo = softpipe_draw_vbo;
@@ -316,9 +325,6 @@ softpipe_create_context(struct pipe_screen *screen,
(struct tgsi_buffer *)
softpipe->tgsi.buffer[PIPE_SHADER_GEOMETRY]);
- if (debug_get_bool_option( "SOFTPIPE_NO_RAST", false ))
- softpipe->no_rast = TRUE;
-
softpipe->vbuf_backend = sp_create_vbuf_backend(softpipe);
if (!softpipe->vbuf_backend)
goto fail;
@@ -352,7 +358,7 @@ softpipe_create_context(struct pipe_screen *screen,
sp_init_surface_functions(softpipe);
#if DO_PSTIPPLE_IN_HELPER_MODULE
- /* create the polgon stipple sampler */
+ /* create the polygon stipple sampler */
softpipe->pstipple.sampler = util_pstipple_create_sampler(&softpipe->pipe);
#endif
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_context.h b/lib/mesa/src/gallium/drivers/softpipe/sp_context.h
index bfa547df1..cd2e498de 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_context.h
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_context.h
@@ -132,7 +132,7 @@ struct softpipe_context {
/** Which vertex shader output slot contains layer */
int8_t layer_slot;
- /** The reduced version of the primitive supplied by the state tracker */
+ /** The reduced version of the primitive supplied by the gallium frontend */
unsigned reduced_api_prim;
/** Derived information about which winding orders to cull */
@@ -205,10 +205,7 @@ struct softpipe_context {
*/
struct softpipe_tex_tile_cache *tex_cache[PIPE_SHADER_TYPES][PIPE_MAX_SHADER_SAMPLER_VIEWS];
- unsigned dump_fs : 1;
- unsigned dump_gs : 1;
- unsigned dump_cs : 1;
- unsigned no_rast : 1;
+ struct pipe_debug_callback debug;
};
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_draw_arrays.c b/lib/mesa/src/gallium/drivers/softpipe/sp_draw_arrays.c
index 91427348a..c02bdaf11 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_draw_arrays.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_draw_arrays.c
@@ -59,8 +59,19 @@
*/
void
softpipe_draw_vbo(struct pipe_context *pipe,
- const struct pipe_draw_info *info)
+ const struct pipe_draw_info *info,
+ const struct pipe_draw_indirect_info *indirect,
+ const struct pipe_draw_start_count *draws,
+ unsigned num_draws)
{
+ if (num_draws > 1) {
+ util_draw_multi(pipe, info, indirect, draws, num_draws);
+ return;
+ }
+
+ if (!indirect && (!draws[0].count || !info->instance_count))
+ return;
+
struct softpipe_context *sp = softpipe_context(pipe);
struct draw_context *draw = sp->draw;
const void *mapped_indices = NULL;
@@ -69,8 +80,8 @@ softpipe_draw_vbo(struct pipe_context *pipe,
if (!softpipe_check_render_cond(sp))
return;
- if (info->indirect) {
- util_draw_indirect(pipe, info);
+ if (indirect && indirect->buffer) {
+ util_draw_indirect(pipe, info, indirect);
return;
}
@@ -129,7 +140,7 @@ softpipe_draw_vbo(struct pipe_context *pipe,
sp->active_statistics_queries > 0);
/* draw! */
- draw_vbo(draw, info);
+ draw_vbo(draw, info, indirect, draws, num_draws);
/* unmap vertex/index buffers - will cause draw module to flush */
for (i = 0; i < sp->num_vertex_buffers; i++) {
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_screen.c b/lib/mesa/src/gallium/drivers/softpipe/sp_screen.c
index 41910c10a..1aaf91196 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_screen.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_screen.c
@@ -26,6 +26,7 @@
**************************************************************************/
+#include "compiler/nir/nir.h"
#include "util/u_memory.h"
#include "util/format/u_format.h"
#include "util/format/u_format_s3tc.h"
@@ -37,7 +38,7 @@
#include "pipe/p_screen.h"
#include "draw/draw_context.h"
-#include "state_tracker/sw_winsys.h"
+#include "frontend/sw_winsys.h"
#include "tgsi/tgsi_exec.h"
#include "sp_texture.h"
@@ -46,12 +47,24 @@
#include "sp_fence.h"
#include "sp_public.h"
-DEBUG_GET_ONCE_BOOL_OPTION(use_llvm, "SOFTPIPE_USE_LLVM", FALSE)
+static const struct debug_named_value sp_debug_options[] = {
+ {"vs", SP_DBG_VS, "dump vertex shader assembly to stderr"},
+ {"gs", SP_DBG_GS, "dump geometry shader assembly to stderr"},
+ {"fs", SP_DBG_FS, "dump fragment shader assembly to stderr"},
+ {"cs", SP_DBG_CS, "dump compute shader assembly to stderr"},
+ {"no_rast", SP_DBG_NO_RAST, "no-ops rasterization, for profiling purposes"},
+ {"use_llvm", SP_DBG_USE_LLVM, "Use LLVM if available for shaders"},
+ {"use_tgsi", SP_DBG_USE_TGSI, "Request TGSI from the API instead of NIR"},
+ DEBUG_NAMED_VALUE_END
+};
+
+int sp_debug;
+DEBUG_GET_ONCE_FLAGS_OPTION(sp_debug, "SOFTPIPE_DEBUG", sp_debug_options, 0)
static const char *
softpipe_get_vendor(struct pipe_screen *screen)
{
- return "VMware, Inc.";
+ return "Mesa/X.org";
}
@@ -61,6 +74,28 @@ softpipe_get_name(struct pipe_screen *screen)
return "softpipe";
}
+static const nir_shader_compiler_options sp_compiler_options = {
+ .fuse_ffma32 = true,
+ .fuse_ffma64 = true,
+ .lower_extract_byte = true,
+ .lower_extract_word = true,
+ .lower_fdph = true,
+ .lower_flrp64 = true,
+ .lower_fmod = true,
+ .lower_rotate = true,
+ .lower_uniforms_to_ubo = true,
+ .lower_vector_cmp = true,
+ .use_interpolated_input_intrinsics = true,
+};
+
+static const void *
+softpipe_get_compiler_options(struct pipe_screen *pscreen,
+ enum pipe_shader_ir ir,
+ enum pipe_shader_type shader)
+{
+ assert(ir == PIPE_SHADER_IR_NIR);
+ return &sp_compiler_options;
+}
static int
softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
@@ -94,9 +129,6 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
return 1;
case PIPE_CAP_TEXTURE_SWIZZLE:
return 1;
- case PIPE_CAP_TEXTURE_BORDER_COLOR_QUIRK:
- case PIPE_CAP_MAX_TEXTURE_UPLOAD_MEMORY_BUDGET:
- return 0;
case PIPE_CAP_MAX_TEXTURE_2D_SIZE:
return 1 << (SP_MAX_TEXTURE_2D_LEVELS - 1);
case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
@@ -115,6 +147,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER:
return 1;
case PIPE_CAP_DEPTH_CLIP_DISABLE:
+ case PIPE_CAP_DEPTH_BOUNDS_TEST:
return 1;
case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
return PIPE_MAX_SO_BUFFERS;
@@ -132,6 +165,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_MAX_VERTEX_ATTRIB_STRIDE:
return 2048;
case PIPE_CAP_PRIMITIVE_RESTART:
+ case PIPE_CAP_PRIMITIVE_RESTART_FIXED_INDEX:
return 1;
case PIPE_CAP_SHADER_STENCIL_EXPORT:
return 1;
@@ -150,10 +184,6 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_MAX_TEXEL_OFFSET:
return 7;
case PIPE_CAP_CONDITIONAL_RENDER:
- return 1;
- case PIPE_CAP_TEXTURE_BARRIER:
- case PIPE_CAP_DEPTH_CLIP_DISABLE_SEPARATE:
- return 0;
case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:
case PIPE_CAP_VERTEX_COLOR_UNCLAMPED: /* draw module */
case PIPE_CAP_VERTEX_COLOR_CLAMPED: /* draw module */
@@ -161,12 +191,8 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_MIXED_COLORBUFFER_FORMATS:
return 1;
case PIPE_CAP_GLSL_FEATURE_LEVEL:
- return 400;
case PIPE_CAP_GLSL_FEATURE_LEVEL_COMPATIBILITY:
- return 140;
- case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
- case PIPE_CAP_TGSI_TEX_TXF_LZ:
- return 0;
+ return 400;
case PIPE_CAP_COMPUTE:
return 1;
case PIPE_CAP_USER_VERTEX_BUFFERS:
@@ -180,12 +206,6 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
return 1;
case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
return 16;
- case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
- case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
- case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
- case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
- case PIPE_CAP_TEXTURE_MULTISAMPLE:
- return 0;
case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
return 64;
case PIPE_CAP_QUERY_TIMESTAMP:
@@ -193,13 +213,10 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
return 1;
case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
return 1;
- case PIPE_CAP_BUFFER_SAMPLER_VIEW_RGBA_ONLY:
- return 0;
case PIPE_CAP_MAX_TEXTURE_BUFFER_SIZE:
return 65536;
case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
return 16;
- case PIPE_CAP_TGSI_TEXCOORD:
case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
return 0;
case PIPE_CAP_MAX_VIEWPORTS:
@@ -211,10 +228,6 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TEXTURE_GATHER_SM5:
case PIPE_CAP_TEXTURE_QUERY_LOD:
return 1;
- case PIPE_CAP_BUFFER_MAP_PERSISTENT_COHERENT:
- case PIPE_CAP_SAMPLE_SHADING:
- case PIPE_CAP_TEXTURE_GATHER_OFFSETS:
- return 0;
case PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION:
return 1;
case PIPE_CAP_TGSI_FS_FINE_DERIVATIVE:
@@ -231,6 +244,14 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
return 1;
case PIPE_CAP_QUERY_SO_OVERFLOW:
return 1;
+ case PIPE_CAP_NIR_IMAGES_AS_DEREF:
+ return 0;
+
+ case PIPE_CAP_SHAREABLE_SHADERS:
+ /* Can't expose shareable shaders because the draw shaders reference the
+ * draw module's state, which is per-context.
+ */
+ return 0;
case PIPE_CAP_VENDOR_ID:
return 0xFFFFFFFF;
@@ -263,81 +284,19 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
return 1;
case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT:
case PIPE_CAP_CULL_DISTANCE:
- return 1;
- case PIPE_CAP_VERTEXID_NOBASE:
- return 0;
- case PIPE_CAP_POLYGON_OFFSET_CLAMP:
- return 0;
case PIPE_CAP_COPY_BETWEEN_COMPRESSED_AND_PLAIN_FORMATS:
case PIPE_CAP_TGSI_ARRAY_COMPONENTS:
+ case PIPE_CAP_TGSI_TEXCOORD:
+ case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
return 1;
case PIPE_CAP_CLEAR_TEXTURE:
return 1;
case PIPE_CAP_MAX_VARYINGS:
return TGSI_EXEC_MAX_INPUT_ATTRIBS;
- case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
- case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
- case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
- case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
- case PIPE_CAP_DEPTH_BOUNDS_TEST:
- case PIPE_CAP_TGSI_TXQS:
- case PIPE_CAP_FORCE_PERSAMPLE_INTERP:
- case PIPE_CAP_SHAREABLE_SHADERS:
- case PIPE_CAP_DRAW_PARAMETERS:
- case PIPE_CAP_TGSI_PACK_HALF_FLOAT:
- case PIPE_CAP_MULTI_DRAW_INDIRECT:
- case PIPE_CAP_MULTI_DRAW_INDIRECT_PARAMS:
- case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL:
- case PIPE_CAP_TGSI_FS_FACE_IS_INTEGER_SYSVAL:
- case PIPE_CAP_INVALIDATE_BUFFER:
- case PIPE_CAP_GENERATE_MIPMAP:
- case PIPE_CAP_STRING_MARKER:
- case PIPE_CAP_SURFACE_REINTERPRET_BLOCKS:
- case PIPE_CAP_QUERY_BUFFER_OBJECT:
- case PIPE_CAP_QUERY_MEMORY_INFO:
case PIPE_CAP_PCI_GROUP:
case PIPE_CAP_PCI_BUS:
case PIPE_CAP_PCI_DEVICE:
case PIPE_CAP_PCI_FUNCTION:
- case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR:
- case PIPE_CAP_PRIMITIVE_RESTART_FOR_PATCHES:
- case PIPE_CAP_TGSI_VOTE:
- case PIPE_CAP_MAX_WINDOW_RECTANGLES:
- case PIPE_CAP_POLYGON_OFFSET_UNITS_UNSCALED:
- case PIPE_CAP_VIEWPORT_SUBPIXEL_BITS:
- case PIPE_CAP_TGSI_CAN_READ_OUTPUTS:
- case PIPE_CAP_NATIVE_FENCE_FD:
- case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
- case PIPE_CAP_FBFETCH:
- case PIPE_CAP_TGSI_MUL_ZERO_WINS:
- case PIPE_CAP_TGSI_CLOCK:
- case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
- case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
- case PIPE_CAP_TGSI_BALLOT:
- case PIPE_CAP_TGSI_TES_LAYER_VIEWPORT:
- case PIPE_CAP_CAN_BIND_CONST_BUFFER_AS_VERTEX:
- case PIPE_CAP_ALLOW_MAPPED_BUFFERS_DURING_EXECUTION:
- case PIPE_CAP_POST_DEPTH_COVERAGE:
- case PIPE_CAP_BINDLESS_TEXTURE:
- case PIPE_CAP_NIR_SAMPLERS_AS_DEREF:
- case PIPE_CAP_MEMOBJ:
- case PIPE_CAP_LOAD_CONSTBUF:
- case PIPE_CAP_TGSI_ANY_REG_AS_ADDRESS:
- case PIPE_CAP_TILE_RASTER_ORDER:
- case PIPE_CAP_MAX_COMBINED_SHADER_OUTPUT_RESOURCES:
- case PIPE_CAP_FRAMEBUFFER_MSAA_CONSTRAINTS:
- case PIPE_CAP_SIGNED_VERTEX_BUFFER_OFFSET:
- case PIPE_CAP_CONTEXT_PRIORITY_MASK:
- case PIPE_CAP_FENCE_SIGNAL:
- case PIPE_CAP_CONSTBUF0_FLAGS:
- case PIPE_CAP_PACKED_UNIFORMS:
- case PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_TRIANGLES:
- case PIPE_CAP_CONSERVATIVE_RASTER_POST_SNAP_POINTS_LINES:
- case PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_TRIANGLES:
- case PIPE_CAP_CONSERVATIVE_RASTER_PRE_SNAP_POINTS_LINES:
- case PIPE_CAP_CONSERVATIVE_RASTER_POST_DEPTH_COVERAGE:
- case PIPE_CAP_MAX_CONSERVATIVE_RASTER_SUBPIXEL_PRECISION_BIAS:
- case PIPE_CAP_PROGRAMMABLE_SAMPLE_LOCATIONS:
return 0;
case PIPE_CAP_MAX_GS_INVOCATIONS:
return 32;
@@ -356,6 +315,16 @@ softpipe_get_shader_param(struct pipe_screen *screen,
enum pipe_shader_cap param)
{
struct softpipe_screen *sp_screen = softpipe_screen(screen);
+
+ switch (param) {
+ case PIPE_SHADER_CAP_PREFERRED_IR:
+ return (sp_debug & SP_DBG_USE_TGSI) ? PIPE_SHADER_IR_TGSI : PIPE_SHADER_IR_NIR;
+ case PIPE_SHADER_CAP_SUPPORTED_IRS:
+ return (1 << PIPE_SHADER_IR_NIR) | (1 << PIPE_SHADER_IR_TGSI);
+ default:
+ break;
+ }
+
switch(shader)
{
case PIPE_SHADER_FRAGMENT:
@@ -378,11 +347,11 @@ softpipe_get_paramf(struct pipe_screen *screen, enum pipe_capf param)
{
switch (param) {
case PIPE_CAPF_MAX_LINE_WIDTH:
- /* fall-through */
+ FALLTHROUGH;
case PIPE_CAPF_MAX_LINE_WIDTH_AA:
return 255.0; /* arbitrary */
case PIPE_CAPF_MAX_POINT_WIDTH:
- /* fall-through */
+ FALLTHROUGH;
case PIPE_CAPF_MAX_POINT_WIDTH_AA:
return 255.0; /* arbitrary */
case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY:
@@ -451,7 +420,7 @@ softpipe_is_format_supported( struct pipe_screen *screen,
/*
* Although possible, it is unnatural to render into compressed or YUV
* surfaces. So disable these here to avoid going into weird paths
- * inside the state trackers.
+ * inside gallium frontends.
*/
if (format_desc->block.width != 1 ||
format_desc->block.height != 1)
@@ -519,6 +488,7 @@ softpipe_destroy_screen( struct pipe_screen *screen )
*/
static void
softpipe_flush_frontbuffer(struct pipe_screen *_screen,
+ struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level, unsigned layer,
void *context_private,
@@ -604,6 +574,8 @@ softpipe_create_screen(struct sw_winsys *winsys)
if (!screen)
return NULL;
+ sp_debug = debug_get_option_sp_debug();
+
screen->winsys = winsys;
screen->base.destroy = softpipe_destroy_screen;
@@ -619,7 +591,8 @@ softpipe_create_screen(struct sw_winsys *winsys)
screen->base.context_create = softpipe_create_context;
screen->base.flush_frontbuffer = softpipe_flush_frontbuffer;
screen->base.get_compute_param = softpipe_get_compute_param;
- screen->use_llvm = debug_get_option_use_llvm();
+ screen->base.get_compiler_options = softpipe_get_compiler_options;
+ screen->use_llvm = sp_debug & SP_DBG_USE_LLVM;
softpipe_init_screen_texture_funcs(&screen->base);
softpipe_init_screen_fence_funcs(&screen->base);
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_state_derived.c b/lib/mesa/src/gallium/drivers/softpipe/sp_state_derived.c
index f34997ab3..d120abf0f 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_state_derived.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_state_derived.c
@@ -420,7 +420,7 @@ update_polygon_stipple_enable(struct softpipe_context *softpipe, unsigned prim)
/* sampler view state */
softpipe_set_sampler_views(&softpipe->pipe, PIPE_SHADER_FRAGMENT,
- unit, 1, &softpipe->pstipple.sampler_view);
+ unit, 1, 0, &softpipe->pstipple.sampler_view);
softpipe->dirty |= SP_NEW_SAMPLER;
}
@@ -428,7 +428,7 @@ update_polygon_stipple_enable(struct softpipe_context *softpipe, unsigned prim)
/* Hopefully this will remain quite simple, otherwise need to pull in
- * something like the state tracker mechanism.
+ * something like the gallium frontend mechanism.
*/
void
softpipe_update_derived(struct softpipe_context *softpipe, unsigned prim)
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c b/lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c
index ec1572646..b6a97c13c 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_state_sampler.c
@@ -41,7 +41,7 @@
#include "sp_tex_sample.h"
#include "sp_tex_tile_cache.h"
#include "sp_screen.h"
-#include "state_tracker/sw_winsys.h"
+#include "frontend/sw_winsys.h"
/**
@@ -100,6 +100,7 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
enum pipe_shader_type shader,
unsigned start,
unsigned num,
+ unsigned unbind_num_trailing_slots,
struct pipe_sampler_view **views)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
@@ -134,6 +135,12 @@ softpipe_set_sampler_views(struct pipe_context *pipe,
memset(sp_sviewdst, 0, sizeof(*sp_sviewsrc));
}
}
+ for (; i < num + unbind_num_trailing_slots; i++) {
+ struct pipe_sampler_view **pview = &softpipe->sampler_views[shader][start + i];
+ pipe_sampler_view_reference(pview, NULL);
+ sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[shader][start + i],
+ NULL);
+ }
/* find highest non-null sampler_views[] entry */
@@ -254,7 +261,7 @@ prepare_shader_sampling(
struct softpipe_screen *screen = softpipe_screen(tex->screen);
struct sw_winsys *winsys = screen->winsys;
addr = winsys->displaytarget_map(winsys, sp_tex->dt,
- PIPE_TRANSFER_READ);
+ PIPE_MAP_READ);
row_stride[0] = sp_tex->stride[0];
img_stride[0] = sp_tex->img_stride[0];
mip_offsets[0] = 0;
@@ -264,7 +271,7 @@ prepare_shader_sampling(
shader_type,
i,
width0, tex->height0, num_layers,
- first_level, last_level,
+ first_level, last_level, 0, 0,
addr,
row_stride, img_stride, mip_offsets);
}
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_state_shader.c b/lib/mesa/src/gallium/drivers/softpipe/sp_state_shader.c
index dc2418f5a..0f25786c6 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_state_shader.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_state_shader.c
@@ -26,11 +26,15 @@
**************************************************************************/
#include "sp_context.h"
+#include "sp_screen.h"
#include "sp_state.h"
#include "sp_fs.h"
#include "sp_texture.h"
+#include "nir.h"
+#include "nir/nir_to_tgsi.h"
#include "pipe/p_defines.h"
+#include "util/ralloc.h"
#include "util/u_memory.h"
#include "util/u_inlines.h"
#include "util/u_pstipple.h"
@@ -38,8 +42,10 @@
#include "draw/draw_vs.h"
#include "draw/draw_gs.h"
#include "tgsi/tgsi_dump.h"
+#include "tgsi/tgsi_from_mesa.h"
#include "tgsi/tgsi_scan.h"
#include "tgsi/tgsi_parse.h"
+#include "compiler/shader_enums.h"
/**
@@ -114,6 +120,48 @@ softpipe_find_fs_variant(struct softpipe_context *sp,
return create_fs_variant(sp, fs, key);
}
+static void
+softpipe_shader_db(struct pipe_context *pipe, const struct tgsi_token *tokens)
+{
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+
+ struct tgsi_shader_info info;
+ tgsi_scan_shader(tokens, &info);
+ pipe_debug_message(&softpipe->debug, SHADER_INFO, "%s shader: %d inst, %d loops, %d temps, %d const, %d imm",
+ _mesa_shader_stage_to_abbrev(tgsi_processor_to_shader_stage(info.processor)),
+ info.num_instructions,
+ info.opcode_count[TGSI_OPCODE_BGNLOOP],
+ info.file_max[TGSI_FILE_TEMPORARY] + 1,
+ info.file_max[TGSI_FILE_CONSTANT] + 1,
+ info.immediate_count);
+}
+
+static void
+softpipe_create_shader_state(struct pipe_context *pipe,
+ struct pipe_shader_state *shader,
+ const struct pipe_shader_state *templ,
+ bool debug)
+{
+ if (templ->type == PIPE_SHADER_IR_NIR) {
+ if (debug)
+ nir_print_shader(templ->ir.nir, stderr);
+
+ shader->tokens = nir_to_tgsi(templ->ir.nir, pipe->screen);
+ } else {
+ assert(templ->type == PIPE_SHADER_IR_TGSI);
+ /* we need to keep a local copy of the tokens */
+ shader->tokens = tgsi_dup_tokens(templ->tokens);
+ }
+
+ shader->type = PIPE_SHADER_IR_TGSI;
+
+ shader->stream_output = templ->stream_output;
+
+ if (debug)
+ tgsi_dump(shader->tokens, 0);
+
+ softpipe_shader_db(pipe, shader->tokens);
+}
static void *
softpipe_create_fs_state(struct pipe_context *pipe,
@@ -122,12 +170,8 @@ softpipe_create_fs_state(struct pipe_context *pipe,
struct softpipe_context *softpipe = softpipe_context(pipe);
struct sp_fragment_shader *state = CALLOC_STRUCT(sp_fragment_shader);
- /* debug */
- if (softpipe->dump_fs)
- tgsi_dump(templ->tokens, 0);
-
- /* we need to keep a local copy of the tokens */
- state->shader.tokens = tgsi_dup_tokens(templ->tokens);
+ softpipe_create_shader_state(pipe, &state->shader, templ,
+ sp_debug & SP_DBG_FS);
/* draw's fs state */
state->draw_shader = draw_create_fragment_shader(softpipe->draw,
@@ -211,13 +255,12 @@ softpipe_create_vs_state(struct pipe_context *pipe,
if (!state)
goto fail;
- /* copy shader tokens, the ones passed in will go away.
- */
- state->shader.tokens = tgsi_dup_tokens(templ->tokens);
- if (state->shader.tokens == NULL)
+ softpipe_create_shader_state(pipe, &state->shader, templ,
+ sp_debug & SP_DBG_VS);
+ if (!state->shader.tokens)
goto fail;
- state->draw_data = draw_create_vertex_shader(softpipe->draw, templ);
+ state->draw_data = draw_create_vertex_shader(softpipe->draw, &state->shader);
if (state->draw_data == NULL)
goto fail;
@@ -273,20 +316,12 @@ softpipe_create_gs_state(struct pipe_context *pipe,
if (!state)
goto fail;
- state->shader = *templ;
-
- if (templ->tokens) {
- /* debug */
- if (softpipe->dump_gs)
- tgsi_dump(templ->tokens, 0);
-
- /* copy shader tokens, the ones passed in will go away.
- */
- state->shader.tokens = tgsi_dup_tokens(templ->tokens);
- if (state->shader.tokens == NULL)
- goto fail;
+ softpipe_create_shader_state(pipe, &state->shader, templ,
+ sp_debug & SP_DBG_GS);
- state->draw_data = draw_create_geometry_shader(softpipe->draw, templ);
+ if (state->shader.tokens) {
+ state->draw_data = draw_create_geometry_shader(softpipe->draw,
+ &state->shader);
if (state->draw_data == NULL)
goto fail;
@@ -338,6 +373,7 @@ softpipe_delete_gs_state(struct pipe_context *pipe, void *gs)
static void
softpipe_set_constant_buffer(struct pipe_context *pipe,
enum pipe_shader_type shader, uint index,
+ bool take_ownership,
const struct pipe_constant_buffer *cb)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
@@ -362,7 +398,12 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
draw_flush(softpipe->draw);
/* note: reference counting */
- pipe_resource_reference(&softpipe->constants[shader][index], constants);
+ if (take_ownership) {
+ pipe_resource_reference(&softpipe->constants[shader][index], NULL);
+ softpipe->constants[shader][index] = constants;
+ } else {
+ pipe_resource_reference(&softpipe->constants[shader][index], constants);
+ }
if (shader == PIPE_SHADER_VERTEX || shader == PIPE_SHADER_GEOMETRY) {
draw_set_mapped_constant_buffer(softpipe->draw, shader, index, data, size);
@@ -382,21 +423,28 @@ static void *
softpipe_create_compute_state(struct pipe_context *pipe,
const struct pipe_compute_state *templ)
{
- struct softpipe_context *softpipe = softpipe_context(pipe);
- const struct tgsi_token *tokens;
- struct sp_compute_shader *state;
- if (templ->ir_type != PIPE_SHADER_IR_TGSI)
- return NULL;
+ struct sp_compute_shader *state = CALLOC_STRUCT(sp_compute_shader);
- tokens = templ->prog;
- /* debug */
- if (softpipe->dump_cs)
- tgsi_dump(tokens, 0);
+ state->shader = *templ;
- state = CALLOC_STRUCT(sp_compute_shader);
+ if (templ->ir_type == PIPE_SHADER_IR_NIR) {
+ nir_shader *s = (void *)templ->prog;
+
+ if (sp_debug & SP_DBG_CS)
+ nir_print_shader(s, stderr);
+
+ state->tokens = (void *)nir_to_tgsi(s, pipe->screen);
+ } else {
+ assert(templ->ir_type == PIPE_SHADER_IR_TGSI);
+ /* we need to keep a local copy of the tokens */
+ state->tokens = tgsi_dup_tokens(templ->prog);
+ }
+
+ if (sp_debug & SP_DBG_CS)
+ tgsi_dump(state->tokens, 0);
+
+ softpipe_shader_db(pipe, state->tokens);
- state->shader = *templ;
- state->tokens = tgsi_dup_tokens(tokens);
tgsi_scan_shader(state->tokens, &state->info);
state->max_sampler = state->info.file_max[TGSI_FILE_SAMPLER];
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_state_vertex.c b/lib/mesa/src/gallium/drivers/softpipe/sp_state_vertex.c
index a7a873639..d46ee6b23 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_state_vertex.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_state_vertex.c
@@ -81,6 +81,8 @@ softpipe_delete_vertex_elements_state(struct pipe_context *pipe, void *velems)
static void
softpipe_set_vertex_buffers(struct pipe_context *pipe,
unsigned start_slot, unsigned count,
+ unsigned unbind_num_trailing_slots,
+ bool take_ownership,
const struct pipe_vertex_buffer *buffers)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
@@ -89,11 +91,14 @@ softpipe_set_vertex_buffers(struct pipe_context *pipe,
util_set_vertex_buffers_count(softpipe->vertex_buffer,
&softpipe->num_vertex_buffers,
- buffers, start_slot, count);
+ buffers, start_slot, count,
+ unbind_num_trailing_slots,
+ take_ownership);
softpipe->dirty |= SP_NEW_VERTEX;
- draw_set_vertex_buffers(softpipe->draw, start_slot, count, buffers);
+ draw_set_vertex_buffers(softpipe->draw, start_slot, count,
+ unbind_num_trailing_slots, buffers);
}
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_tex_sample.c b/lib/mesa/src/gallium/drivers/softpipe/sp_tex_sample.c
index d3f67c642..87259301d 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_tex_sample.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_tex_sample.c
@@ -1638,7 +1638,7 @@ get_gather_value(const struct sp_sampler_view *sp_sview,
case PIPE_SWIZZLE_0:
return 0.0;
case PIPE_SWIZZLE_1:
- return 1.0;
+ return sp_sview->oneval;
default:
return tx[chan][swizzle];
}
@@ -2320,7 +2320,7 @@ create_filter_table(void)
for (i = 0; i < WEIGHT_LUT_SIZE; ++i) {
const float alpha = 2;
const float r2 = (float) i / (float) (WEIGHT_LUT_SIZE - 1);
- const float weight = (float) exp(-alpha * r2);
+ const float weight = (float) expf(-alpha * r2);
lut[i] = weight;
}
weightLut = lut;
@@ -2884,12 +2884,12 @@ do_swizzling(const struct pipe_sampler_view *sview,
float in[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE],
float out[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE])
{
+ struct sp_sampler_view *sp_sview = (struct sp_sampler_view *)sview;
int j;
const unsigned swizzle_r = sview->swizzle_r;
const unsigned swizzle_g = sview->swizzle_g;
const unsigned swizzle_b = sview->swizzle_b;
const unsigned swizzle_a = sview->swizzle_a;
- float oneval = util_format_is_pure_integer(sview->format) ? uif(1) : 1.0f;
switch (swizzle_r) {
case PIPE_SWIZZLE_0:
@@ -2898,7 +2898,7 @@ do_swizzling(const struct pipe_sampler_view *sview,
break;
case PIPE_SWIZZLE_1:
for (j = 0; j < 4; j++)
- out[0][j] = oneval;
+ out[0][j] = sp_sview->oneval;
break;
default:
assert(swizzle_r < 4);
@@ -2913,7 +2913,7 @@ do_swizzling(const struct pipe_sampler_view *sview,
break;
case PIPE_SWIZZLE_1:
for (j = 0; j < 4; j++)
- out[1][j] = oneval;
+ out[1][j] = sp_sview->oneval;
break;
default:
assert(swizzle_g < 4);
@@ -2928,7 +2928,7 @@ do_swizzling(const struct pipe_sampler_view *sview,
break;
case PIPE_SWIZZLE_1:
for (j = 0; j < 4; j++)
- out[2][j] = oneval;
+ out[2][j] = sp_sview->oneval;
break;
default:
assert(swizzle_b < 4);
@@ -2943,7 +2943,7 @@ do_swizzling(const struct pipe_sampler_view *sview,
break;
case PIPE_SWIZZLE_1:
for (j = 0; j < 4; j++)
- out[3][j] = oneval;
+ out[3][j] = sp_sview->oneval;
break;
default:
assert(swizzle_a < 4);
@@ -3321,12 +3321,12 @@ sp_get_dims(const struct sp_sampler_view *sp_sview,
switch (view->target) {
case PIPE_TEXTURE_1D_ARRAY:
dims[1] = view->u.tex.last_layer - view->u.tex.first_layer + 1;
- /* fallthrough */
+ FALLTHROUGH;
case PIPE_TEXTURE_1D:
return;
case PIPE_TEXTURE_2D_ARRAY:
dims[2] = view->u.tex.last_layer - view->u.tex.first_layer + 1;
- /* fallthrough */
+ FALLTHROUGH;
case PIPE_TEXTURE_2D:
case PIPE_TEXTURE_CUBE:
case PIPE_TEXTURE_RECT:
@@ -3599,7 +3599,7 @@ softpipe_create_sampler_view(struct pipe_context *pipe,
#ifdef DEBUG
/*
* This is possibly too lenient, but the primary reason is just
- * to catch state trackers which forget to initialize this, so
+ * to catch gallium frontends which forget to initialize this, so
* it only catches clearly impossible view targets.
*/
if (view->target != resource->target) {
@@ -3638,6 +3638,8 @@ softpipe_create_sampler_view(struct pipe_context *pipe,
sview->xpot = util_logbase2( resource->width0 );
sview->ypot = util_logbase2( resource->height0 );
+
+ sview->oneval = util_format_is_pure_integer(view->format) ? uif(1) : 1.0f;
}
return (struct pipe_sampler_view *) sview;
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_tex_sample.h b/lib/mesa/src/gallium/drivers/softpipe/sp_tex_sample.h
index 96fab8e33..2770acac7 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_tex_sample.h
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_tex_sample.h
@@ -122,6 +122,8 @@ struct sp_sampler_view
compute_lambda_func compute_lambda;
compute_lambda_from_grad_func compute_lambda_from_grad;
union pipe_color_union border_color;
+ /* Value to use for PIPE_SWIZZLE_1 (integer vs float) */
+ float oneval;
};
struct sp_filter_funcs {
diff --git a/lib/mesa/src/gallium/drivers/softpipe/sp_texture.c b/lib/mesa/src/gallium/drivers/softpipe/sp_texture.c
index a8f0e6cee..b4624f50e 100644
--- a/lib/mesa/src/gallium/drivers/softpipe/sp_texture.c
+++ b/lib/mesa/src/gallium/drivers/softpipe/sp_texture.c
@@ -44,7 +44,7 @@
#include "sp_texture.h"
#include "sp_screen.h"
-#include "state_tracker/sw_winsys.h"
+#include "frontend/sw_winsys.h"
/**
@@ -348,7 +348,7 @@ softpipe_surface_destroy(struct pipe_context *pipe,
* \param pipe rendering context
* \param resource the resource to transfer in/out of
* \param level which mipmap level
- * \param usage bitmask of PIPE_TRANSFER_x flags
+ * \param usage bitmask of PIPE_MAP_x flags
* \param box the 1D/2D/3D region of interest
*/
static void *
@@ -394,9 +394,9 @@ softpipe_transfer_map(struct pipe_context *pipe,
* Transfers, like other pipe operations, must happen in order, so flush the
* context if necessary.
*/
- if (!(usage & PIPE_TRANSFER_UNSYNCHRONIZED)) {
- boolean read_only = !(usage & PIPE_TRANSFER_WRITE);
- boolean do_not_block = !!(usage & PIPE_TRANSFER_DONTBLOCK);
+ if (!(usage & PIPE_MAP_UNSYNCHRONIZED)) {
+ boolean read_only = !(usage & PIPE_MAP_WRITE);
+ boolean do_not_block = !!(usage & PIPE_MAP_DONTBLOCK);
if (!softpipe_flush_resource(pipe, resource,
level, box->depth > 1 ? -1 : box->z,
0, /* flush_flags */
@@ -468,7 +468,7 @@ softpipe_transfer_unmap(struct pipe_context *pipe,
winsys->displaytarget_unmap(winsys, spr->dt);
}
- if (transfer->usage & PIPE_TRANSFER_WRITE) {
+ if (transfer->usage & PIPE_MAP_WRITE) {
/* Mark the texture as dirty to expire the tile caches. */
spr->timestamp++;
}