diff --git a/docs/features.txt b/docs/features.txt index bed129f3b5302ebb6d0d4fd91a7335b7f4876b1a..0fb5675a13cdff044566970aeaa46810391df1f6 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -213,7 +213,7 @@ GL 4.4, GLSL 4.40 -- all DONE: i965/gen8+, nvc0, r600, radeonsi, llvmpipe, zink GL 4.5, GLSL 4.50 -- all DONE: nvc0, r600, radeonsi, llvmpipe, zink GL_ARB_ES3_1_compatibility DONE (i965/hsw+, softpipe, virgl) - GL_ARB_clip_control DONE (freedreno, i965, nv50, softpipe, virgl, lima) + GL_ARB_clip_control DONE (freedreno, i965, nv50, softpipe, virgl, lima, panfrost) GL_ARB_conditional_render_inverted DONE (freedreno, i965, nv50, softpipe, virgl, panfrost, d3d12) GL_ARB_cull_distance DONE (freedreno/a6xx, i965, nv50, softpipe, virgl) GL_ARB_derivative_control DONE (i965, nv50, softpipe, virgl) diff --git a/meson.build b/meson.build index 9f93ad52be76ca236779416e8b7f69e5ee0dd919..d0bb7342938aa2026bb9c9630d283a577bed5ff5 100644 --- a/meson.build +++ b/meson.build @@ -890,7 +890,8 @@ if with_gallium_st_nine error('The nine state tracker requires gallium softpipe/llvmpipe.') elif not (with_gallium_radeonsi or with_gallium_nouveau or with_gallium_r600 or with_gallium_r300 or with_gallium_svga or with_gallium_i915 - or with_gallium_iris or with_gallium_crocus or with_gallium_zink) + or with_gallium_iris or with_gallium_crocus or with_gallium_zink + or with_gallium_panfrost) error('The nine state tracker requires at least one non-swrast gallium driver.') endif if not with_dri3 diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 111de3f0e24712b7a2cc99fddc7113d9b2bf6c9a..b0a9e5de61bf67cd6e9b4213ccfa561d2b0a1284 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -1251,6 +1251,12 @@ cso_single_sampler(struct cso_context *ctx, enum pipe_shader_type shader_stage, ctx->max_sampler_seen = MAX2(ctx->max_sampler_seen, (int)idx); } +void +cso_set_max_sampler(struct cso_context *ctx, int max_sampler_seen) +{ + ctx->max_sampler_seen = max_sampler_seen; +} + /** * Send staged sampler state to the driver. */ diff --git a/src/gallium/auxiliary/cso_cache/cso_context.h b/src/gallium/auxiliary/cso_cache/cso_context.h index 3c5b606420979ae3aa031f2e35fe480417a47bdb..f6eaa6a499f36a93aca5076b7b9769585256359a 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.h +++ b/src/gallium/auxiliary/cso_cache/cso_context.h @@ -80,6 +80,9 @@ void cso_single_sampler(struct cso_context *cso, enum pipe_shader_type shader_stage, unsigned idx, const struct pipe_sampler_state *states); +void +cso_set_max_sampler(struct cso_context *ctx, int max_sampler_seen); + void cso_single_sampler_done(struct cso_context *cso, enum pipe_shader_type shader_stage); diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c index c103c0062523a2bbe2afe6e3c91a72319be81f63..bc5c16ea44bbbf8f016ffcbd24e2069379c850dc 100644 --- a/src/gallium/auxiliary/nir/tgsi_to_nir.c +++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c @@ -2603,7 +2603,7 @@ tgsi_to_nir(const void *tgsi_tokens, uint8_t key[CACHE_KEY_SIZE]; unsigned processor; - if (allow_disk_cache) + if (allow_disk_cache && screen->get_disk_shader_cache) cache = screen->get_disk_shader_cache(screen); /* Look first in the cache */ diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 1ef8d09bd2b7b6987eb7a2a9a920a0d2ffd9eedf..27b1d9178fafa26ef7240fa14ef043adb7252cad 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -29,6 +29,7 @@ #include "util/u_helpers.h" #include "util/u_draw.h" #include "util/u_memory.h" +#include "util/u_viewport.h" #include "pipe/p_defines.h" #include "pipe/p_state.h" #include "gallium/auxiliary/util/u_blend.h" @@ -693,8 +694,8 @@ panfrost_emit_viewport(struct panfrost_batch *batch) float vp_maxx = vp->translate[0] + fabsf(vp->scale[0]); float vp_miny = vp->translate[1] - fabsf(vp->scale[1]); float vp_maxy = vp->translate[1] + fabsf(vp->scale[1]); - float minz = (vp->translate[2] - fabsf(vp->scale[2])); - float maxz = (vp->translate[2] + fabsf(vp->scale[2])); + float minz, maxz; + util_viewport_zmin_zmax(vp, rast->clip_halfz, &minz, &maxz); /* Scissor to the intersection of viewport and to the scissor, clamped * to the framebuffer */ diff --git a/src/gallium/drivers/panfrost/pan_job.c b/src/gallium/drivers/panfrost/pan_job.c index 6e051fd892d7197f336a18561064dcf71da62a12..b2820c29ced6bacff724329faefc1a3191e64c8d 100644 --- a/src/gallium/drivers/panfrost/pan_job.c +++ b/src/gallium/drivers/panfrost/pan_job.c @@ -529,22 +529,22 @@ panfrost_batch_to_fb_info(const struct panfrost_batch *batch, fb->zs.discard.z = !reserve && !(batch->resolve & PIPE_CLEAR_DEPTH); fb->zs.discard.s = !reserve && !(batch->resolve & PIPE_CLEAR_STENCIL); - if (!fb->zs.clear.z && + if (!fb->zs.clear.z && z_rsrc && ((batch->read & PIPE_CLEAR_DEPTH) || ((batch->draws & PIPE_CLEAR_DEPTH) && - z_rsrc && BITSET_TEST(z_rsrc->valid.data, z_view->first_level)))) + BITSET_TEST(z_rsrc->valid.data, z_view->first_level)))) fb->zs.preload.z = true; - if (!fb->zs.clear.s && + if (!fb->zs.clear.s && s_rsrc && ((batch->read & PIPE_CLEAR_STENCIL) || ((batch->draws & PIPE_CLEAR_STENCIL) && - s_rsrc && BITSET_TEST(s_rsrc->valid.data, s_view->first_level)))) + BITSET_TEST(s_rsrc->valid.data, s_view->first_level)))) fb->zs.preload.s = true; /* Preserve both component if we have a combined ZS view and * one component needs to be preserved. */ - if (s_view == z_view && fb->zs.discard.z != fb->zs.discard.s) { + if (z_view && s_view == z_view && fb->zs.discard.z != fb->zs.discard.s) { bool valid = BITSET_TEST(z_rsrc->valid.data, z_view->first_level); fb->zs.discard.z = false; @@ -857,6 +857,8 @@ panfrost_batch_clear(struct panfrost_batch *batch, for (unsigned i = 0; i < ctx->pipe_framebuffer.nr_cbufs; ++i) { if (!(buffers & (PIPE_CLEAR_COLOR0 << i))) continue; + if (!ctx->pipe_framebuffer.cbufs[i]) + continue; enum pipe_format format = ctx->pipe_framebuffer.cbufs[i]->format; pan_pack_color(batch->clear_color[i], color, format, false); diff --git a/src/gallium/drivers/panfrost/pan_resource.c b/src/gallium/drivers/panfrost/pan_resource.c index 583b86d9545821b8a0c1be9bc16394f0fc97d9d6..8bdd64d3bb511785f995c2092b4987486e051627 100644 --- a/src/gallium/drivers/panfrost/pan_resource.c +++ b/src/gallium/drivers/panfrost/pan_resource.c @@ -757,6 +757,71 @@ panfrost_resource_destroy(struct pipe_screen *screen, free(rsrc); } +static void +panfrost_clear_render_target(struct pipe_context *pipe, + struct pipe_surface *dst, + const union pipe_color_union *color, + unsigned dstx, unsigned dsty, + unsigned width, unsigned height, + bool render_condition_enabled) +{ + struct panfrost_context *ctx = pan_context(pipe); + + /* TODO: dstx, etc. */ + + struct pipe_framebuffer_state tmp = {0}; + util_copy_framebuffer_state(&tmp, &ctx->pipe_framebuffer); + + struct pipe_framebuffer_state fb = { + .width = dst->width, + .height = dst->height, + .layers = 1, + .samples = 1, + .nr_cbufs = 1, + .cbufs[0] = dst, + }; + pipe->set_framebuffer_state(pipe, &fb); + + struct panfrost_batch *batch = panfrost_get_fresh_batch_for_fbo(ctx, "Clear render target"); + panfrost_batch_clear(batch, PIPE_CLEAR_COLOR0, color, 0, 0); + + pipe->set_framebuffer_state(pipe, &tmp); + util_unreference_framebuffer_state(&tmp); +} + +static void +panfrost_clear_depth_stencil(struct pipe_context *pipe, + struct pipe_surface *dst, + unsigned clear_flags, + double depth, unsigned stencil, + unsigned dstx, unsigned dsty, + unsigned width, unsigned height, + bool render_condition_enabled) +{ + struct panfrost_context *ctx = pan_context(pipe); + + /* TODO: dstx, etc. */ + + struct pipe_framebuffer_state tmp; + util_copy_framebuffer_state(&tmp, &ctx->pipe_framebuffer); + + struct pipe_framebuffer_state fb = { + .width = dst->width, + .height = dst->height, + .layers = 1, + .samples = 1, + .nr_cbufs = 0, + .zsbuf = dst, + }; + pipe->set_framebuffer_state(pipe, &fb); + + struct panfrost_batch *batch = panfrost_get_fresh_batch_for_fbo(ctx, "Clear depth/stencil"); + panfrost_batch_clear(batch, clear_flags, NULL, depth, stencil); + + pipe->set_framebuffer_state(pipe, &tmp); + util_unreference_framebuffer_state(&tmp); +} + /* Most of the time we can do CPU-side transfers, but sometimes we need to use * the 3D pipe for this. Let's wrap u_blitter to blit to/from staging textures. * Code adapted from freedreno */ @@ -1444,6 +1509,8 @@ panfrost_resource_context_init(struct pipe_context *pctx) pctx->texture_unmap = u_transfer_helper_transfer_unmap; pctx->create_surface = panfrost_create_surface; pctx->surface_destroy = panfrost_surface_destroy; + pctx->clear_render_target = panfrost_clear_render_target; + pctx->clear_depth_stencil = panfrost_clear_depth_stencil; pctx->resource_copy_region = util_resource_copy_region; pctx->blit = panfrost_blit; pctx->generate_mipmap = panfrost_generate_mipmap; diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index b6e40b1db3bbebab11f1159c5d5d04cdbbf48e05..deced3d10d2a9e6ff2b88b7e21413064e845600a 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -122,6 +122,7 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_FRAMEBUFFER_NO_ATTACHMENT: case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: case PIPE_CAP_SHADER_PACK_HALF_FLOAT: + case PIPE_CAP_CLIP_HALFZ: return 1; case PIPE_CAP_MAX_RENDER_TARGETS: diff --git a/src/gallium/frontends/nine/nine_ff.c b/src/gallium/frontends/nine/nine_ff.c index 6c9f896ad21d194fece18068abfff3a8026721c1..2af51bebf8574341a9c46692ba45c95ca15d8c68 100644 --- a/src/gallium/frontends/nine/nine_ff.c +++ b/src/gallium/frontends/nine/nine_ff.c @@ -1410,7 +1410,7 @@ nine_ff_build_ps(struct NineDevice9 *device, struct nine_ff_ps_key *key) struct ureg_src texture_coord = ps.vT[s]; struct ureg_dst delta; switch (key->ts[s].textarget) { - case 0: target = TGSI_TEXTURE_1D; break; + case 0: target = TGSI_TEXTURE_2D; break; case 1: target = TGSI_TEXTURE_2D; break; case 2: target = TGSI_TEXTURE_3D; break; case 3: target = TGSI_TEXTURE_CUBE; break; diff --git a/src/gallium/frontends/nine/nine_shader.c b/src/gallium/frontends/nine/nine_shader.c index aa2680160f98c8ebd8f6920f9d999646d828a870..9c4b6240f86327c13d6da10ff9683374ae531565 100644 --- a/src/gallium/frontends/nine/nine_shader.c +++ b/src/gallium/frontends/nine/nine_shader.c @@ -2159,7 +2159,7 @@ static inline unsigned d3dstt_to_tgsi_tex(BYTE sampler_type) { switch (sampler_type) { - case NINED3DSTT_1D: return TGSI_TEXTURE_1D; + case NINED3DSTT_1D: return TGSI_TEXTURE_2D; case NINED3DSTT_2D: return TGSI_TEXTURE_2D; case NINED3DSTT_VOLUME: return TGSI_TEXTURE_3D; case NINED3DSTT_CUBE: return TGSI_TEXTURE_CUBE; @@ -2172,7 +2172,7 @@ static inline unsigned d3dstt_to_tgsi_tex_shadow(BYTE sampler_type) { switch (sampler_type) { - case NINED3DSTT_1D: return TGSI_TEXTURE_SHADOW1D; + case NINED3DSTT_1D: return TGSI_TEXTURE_SHADOW2D; case NINED3DSTT_2D: return TGSI_TEXTURE_SHADOW2D; case NINED3DSTT_VOLUME: case NINED3DSTT_CUBE: @@ -2186,7 +2186,7 @@ ps1x_sampler_type(const struct nine_shader_info *info, unsigned stage) { boolean shadow = !!(info->sampler_mask_shadow & (1 << stage)); switch ((info->sampler_ps1xtypes >> (stage * 2)) & 0x3) { - case 1: return shadow ? TGSI_TEXTURE_SHADOW1D : TGSI_TEXTURE_1D; + case 1: return shadow ? TGSI_TEXTURE_SHADOW2D : TGSI_TEXTURE_2D; case 0: return shadow ? TGSI_TEXTURE_SHADOW2D : TGSI_TEXTURE_2D; case 3: return TGSI_TEXTURE_3D; default: diff --git a/src/gallium/frontends/nine/nine_state.c b/src/gallium/frontends/nine/nine_state.c index 1365f1c937d0306c40130156d8603154778d2b98..4244c5f3f1ade607e2c9b8216df07599f016f365 100644 --- a/src/gallium/frontends/nine/nine_state.c +++ b/src/gallium/frontends/nine/nine_state.c @@ -840,7 +840,7 @@ update_vertex_elements(struct NineDevice9 *device) const struct NineVertexShader9 *vs; unsigned n, b, i; int index; - char vdecl_index_map[16]; /* vs->num_inputs <= 16 */ + int8_t vdecl_index_map[16]; /* vs->num_inputs <= 16 */ uint16_t used_streams = 0; int dummy_vbo_stream = -1; BOOL need_dummy_vbo = FALSE; @@ -1040,8 +1040,10 @@ update_textures_and_samplers(struct NineDevice9 *device) false, view); context->enabled_sampler_count_ps = num_textures; - if (commit_samplers) + if (commit_samplers) { + cso_set_max_sampler(context->cso, num_textures - 1); cso_single_sampler_done(context->cso, PIPE_SHADER_FRAGMENT); + } commit_samplers = FALSE; sampler_mask = context->programmable_vs ? context->vs->sampler_mask : 0; @@ -1085,8 +1087,10 @@ update_textures_and_samplers(struct NineDevice9 *device) false, view); context->enabled_sampler_count_vs = num_textures; - if (commit_samplers) + if (commit_samplers) { + cso_set_max_sampler(context->cso, num_textures - 1); cso_single_sampler_done(context->cso, PIPE_SHADER_VERTEX); + } } /* State commit only */ @@ -3041,7 +3045,7 @@ update_vertex_elements_sw(struct NineDevice9 *device) const struct NineVertexShader9 *vs; unsigned n, b, i; int index; - char vdecl_index_map[16]; /* vs->num_inputs <= 16 */ + int8_t vdecl_index_map[16]; /* vs->num_inputs <= 16 */ char used_streams[device->caps.MaxStreams]; int dummy_vbo_stream = -1; BOOL need_dummy_vbo = FALSE; diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c index ced9d5bac2deafc8b53f737602d0918f348a1740..cab2347c57db04855f945a68685d72db43a2ea6e 100644 --- a/src/gallium/targets/d3dadapter9/drm.c +++ b/src/gallium/targets/d3dadapter9/drm.c @@ -47,6 +47,12 @@ #define DBG_CHANNEL DBG_ADAPTER +#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) +#define DEFAULT_THREADSUBMIT true +#else +#define DEFAULT_THREADSUBMIT false +#endif + const driOptionDescription __driConfigOptionsNine[] = { DRI_CONF_SECTION_PERFORMANCE DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_DEF_INTERVAL_1) @@ -54,7 +60,7 @@ const driOptionDescription __driConfigOptionsNine[] = { DRI_CONF_SECTION_NINE DRI_CONF_NINE_OVERRIDEVENDOR(-1) DRI_CONF_NINE_THROTTLE(-2) - DRI_CONF_NINE_THREADSUBMIT(true) + DRI_CONF_NINE_THREADSUBMIT(DEFAULT_THREADSUBMIT) DRI_CONF_NINE_ALLOWDISCARDDELAYEDRELEASE(true) DRI_CONF_NINE_TEARFREEDISCARD(true) DRI_CONF_NINE_CSMT(-1) diff --git a/src/gallium/targets/d3dadapter9/meson.build b/src/gallium/targets/d3dadapter9/meson.build index c51c9ff1bf36a003fdce62112dc70668fffdb08f..2bca29357cae4d9c552901080f0afb9a047fd5ff 100644 --- a/src/gallium/targets/d3dadapter9/meson.build +++ b/src/gallium/targets/d3dadapter9/meson.build @@ -64,7 +64,8 @@ libgallium_nine = shared_library( dep_selinux, dep_libdrm, dep_llvm, dep_thread, idep_xmlconfig, idep_mesautil, idep_nir, driver_swrast, driver_r300, driver_r600, driver_radeonsi, driver_nouveau, - driver_i915, driver_svga, driver_iris, driver_crocus, driver_zink + driver_i915, driver_svga, driver_iris, driver_crocus, driver_zink, + driver_kmsro, driver_panfrost, ], name_prefix : '', version : '.'.join(nine_version),