#include <stdio.h>
#include <map>
-/* MSVC case instensitive compare */
-#if defined(PIPE_CC_MSVC)
- #define strcasecmp lstrcmpiA
-#endif
-
/*
* Max texture sizes
* XXX Check max texture size values against core and sampler.
#define SWR_MAX_TEXTURE_CUBE_LEVELS 14 /* 8K x 8K for now */
#define SWR_MAX_TEXTURE_ARRAY_LAYERS 512 /* 8K x 512 / 8K x 8K x 512 */
+/* Default max client_copy_limit */
+#define SWR_CLIENT_COPY_LIMIT 32768
+
/* Flag indicates creation of alternate surface, to prevent recursive loop
* in resource creation when msaa_force_enable is set. */
#define SWR_RESOURCE_FLAG_ALT_SURFACE (PIPE_RESOURCE_FLAG_DRV_PRIV << 0)
return 1;
/* MSAA support
- * If user has explicitly set max_sample_count = 0 (via SWR_MSAA_MAX_COUNT)
- * then disable all MSAA support and go back to old caps. */
+ * If user has explicitly set max_sample_count = 1 (via SWR_MSAA_MAX_COUNT)
+ * then disable all MSAA support and go back to old (FAKE_SW_MSAA) caps. */
case PIPE_CAP_TEXTURE_MULTISAMPLE:
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
- return swr_screen(screen)->msaa_max_count ? 1 : 0;
+ return (swr_screen(screen)->msaa_max_count > 1) ? 1 : 0;
case PIPE_CAP_FAKE_SW_MSAA:
- return swr_screen(screen)->msaa_max_count ? 0 : 1;
+ return (swr_screen(screen)->msaa_max_count > 1) ? 0 : 1;
/* unsupported features */
case PIPE_CAP_ANISOTROPIC_FILTER:
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_QUERY_SO_OVERFLOW:
+ case PIPE_CAP_MEMOBJ:
return 0;
case PIPE_CAP_VENDOR_ID:
/* Attach it to the multisample resource */
msaa_res->resolve_target = alt;
+
+ /* Hang resolve surface state off the multisample surface state to so
+ * StoreTiles knows where to resolve the surface. */
+ msaa_res->swr.pAuxBaseAddress = (uint8_t *)&swr_resource(alt)->swr;
}
return true; /* success */
swr_fence_work_free(screen->flush_fence, spr->swr.pBaseAddress, true);
swr_fence_work_free(screen->flush_fence,
spr->secondary.pBaseAddress, true);
+
+ /* If work queue grows too large, submit a fence to force queue to
+ * drain. This is mainly to decrease the amount of memory used by the
+ * piglit streaming-texture-leak test */
+ if (screen->pipe && swr_fence(screen->flush_fence)->work.count > 64)
+ swr_fence_submit(swr_context(screen->pipe), screen->flush_fence);
}
FREE(spr);
struct sw_winsys *winsys = screen->winsys;
struct swr_resource *spr = swr_resource(resource);
struct pipe_context *pipe = screen->pipe;
+ struct swr_context *ctx = swr_context(pipe);
if (pipe) {
swr_fence_finish(p_screen, NULL, screen->flush_fence, 0);
swr_resource_unused(resource);
- SwrEndFrame(swr_context(pipe)->swrContext);
+ ctx->api.pfnSwrEndFrame(ctx->swrContext);
}
- /* Multisample surfaces need to be resolved before present */
+ /* Multisample resolved into resolve_target at flush with store_resource */
if (pipe && spr->swr.numSamples > 1) {
struct pipe_resource *resolve_target = spr->resolve_target;
- /* Do an inline surface resolve into the resolve target resource
- * XXX: This works, just not optimal. Work on using a pipelined blit. */
- swr_do_msaa_resolve(resource, resolve_target);
-
/* Once resolved, copy into display target */
SWR_SURFACE_STATE *resolve = &swr_resource(resolve_target)->swr;
FREE(screen);
}
+
+static void
+swr_validate_env_options(struct swr_screen *screen)
+{
+ /* The client_copy_limit sets a maximum on the amount of user-buffer memory
+ * copied to scratch space on a draw. Past this, the draw will access
+ * user-buffer directly and then block. This is faster than queuing many
+ * large client draws. */
+ screen->client_copy_limit = SWR_CLIENT_COPY_LIMIT;
+ int client_copy_limit =
+ debug_get_num_option("SWR_CLIENT_COPY_LIMIT", SWR_CLIENT_COPY_LIMIT);
+ if (client_copy_limit > 0)
+ screen->client_copy_limit = client_copy_limit;
+
+ /* XXX msaa under development, disable by default for now */
+ screen->msaa_max_count = 1; /* was SWR_MAX_NUM_MULTISAMPLES; */
+
+ /* validate env override values, within range and power of 2 */
+ int msaa_max_count = debug_get_num_option("SWR_MSAA_MAX_COUNT", 1);
+ if (msaa_max_count != 1) {
+ if ((msaa_max_count < 1) || (msaa_max_count > SWR_MAX_NUM_MULTISAMPLES)
+ || !util_is_power_of_two(msaa_max_count)) {
+ fprintf(stderr, "SWR_MSAA_MAX_COUNT invalid: %d\n", msaa_max_count);
+ fprintf(stderr, "must be power of 2 between 1 and %d" \
+ " (or 1 to disable msaa)\n",
+ SWR_MAX_NUM_MULTISAMPLES);
+ msaa_max_count = 1;
+ }
+
+ fprintf(stderr, "SWR_MSAA_MAX_COUNT: %d\n", msaa_max_count);
+ if (msaa_max_count == 1)
+ fprintf(stderr, "(msaa disabled)\n");
+
+ screen->msaa_max_count = msaa_max_count;
+ }
+
+ screen->msaa_force_enable = debug_get_bool_option(
+ "SWR_MSAA_FORCE_ENABLE", false);
+ if (screen->msaa_force_enable)
+ fprintf(stderr, "SWR_MSAA_FORCE_ENABLE: true\n");
+}
+
+
PUBLIC
struct pipe_screen *
swr_create_screen_internal(struct sw_winsys *winsys)
if (!screen)
return NULL;
- if (!getenv("KNOB_MAX_PRIMS_PER_DRAW")) {
- g_GlobalKnobs.MAX_PRIMS_PER_DRAW.Value(49152);
- }
-
if (!lp_build_init()) {
FREE(screen);
return NULL;
screen->base.flush_frontbuffer = swr_flush_frontbuffer;
- screen->hJitMgr = JitCreateContext(KNOB_SIMD_WIDTH, KNOB_ARCH_STR, "swr");
+ // Pass in "" for architecture for run-time determination
+ screen->hJitMgr = JitCreateContext(KNOB_SIMD_WIDTH, "", "swr");
swr_fence_init(&screen->base);
util_format_s3tc_init();
- /* XXX msaa under development, disable by default for now */
- screen->msaa_max_count = 0; /* was SWR_MAX_NUM_MULTISAMPLES; */
-
- /* validate env override values, within range and power of 2 */
- int msaa_max_count = debug_get_num_option("SWR_MSAA_MAX_COUNT", 0);
- if (msaa_max_count) {
- if ((msaa_max_count < 0) || (msaa_max_count > SWR_MAX_NUM_MULTISAMPLES)
- || !util_is_power_of_two(msaa_max_count)) {
- fprintf(stderr, "SWR_MSAA_MAX_COUNT invalid: %d\n", msaa_max_count);
- fprintf(stderr, "must be power of 2 between 1 and %d" \
- " (or 0 to disable msaa)\n",
- SWR_MAX_NUM_MULTISAMPLES);
- msaa_max_count = 0;
- }
-
- fprintf(stderr, "SWR_MSAA_MAX_COUNT: %d\n", msaa_max_count);
- if (!msaa_max_count)
- fprintf(stderr, "(msaa disabled)\n");
-
- screen->msaa_max_count = msaa_max_count;
- }
-
- screen->msaa_force_enable = debug_get_bool_option(
- "SWR_MSAA_FORCE_ENABLE", false);
- if (screen->msaa_force_enable)
- fprintf(stderr, "SWR_MSAA_FORCE_ENABLE: true\n");
+ swr_validate_env_options(screen);
return &screen->base;
}