#include "util/u_draw.h"
#include "util/u_prim.h"
-/*
- * Convert mesa PIPE_PRIM_X to SWR enum PRIMITIVE_TOPOLOGY
- */
-static INLINE enum PRIMITIVE_TOPOLOGY
-swr_convert_prim_topology(const unsigned mode)
-{
- switch (mode) {
- case PIPE_PRIM_POINTS:
- return TOP_POINT_LIST;
- case PIPE_PRIM_LINES:
- return TOP_LINE_LIST;
- case PIPE_PRIM_LINE_LOOP:
- return TOP_LINE_LOOP;
- case PIPE_PRIM_LINE_STRIP:
- return TOP_LINE_STRIP;
- case PIPE_PRIM_TRIANGLES:
- return TOP_TRIANGLE_LIST;
- case PIPE_PRIM_TRIANGLE_STRIP:
- return TOP_TRIANGLE_STRIP;
- case PIPE_PRIM_TRIANGLE_FAN:
- return TOP_TRIANGLE_FAN;
- case PIPE_PRIM_QUADS:
- return TOP_QUAD_LIST;
- case PIPE_PRIM_QUAD_STRIP:
- return TOP_QUAD_STRIP;
- case PIPE_PRIM_POLYGON:
- return TOP_TRIANGLE_FAN; /* XXX TOP_POLYGON; */
- case PIPE_PRIM_LINES_ADJACENCY:
- return TOP_LINE_LIST_ADJ;
- case PIPE_PRIM_LINE_STRIP_ADJACENCY:
- return TOP_LISTSTRIP_ADJ;
- case PIPE_PRIM_TRIANGLES_ADJACENCY:
- return TOP_TRI_LIST_ADJ;
- case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
- return TOP_TRI_STRIP_ADJ;
- default:
- assert(0 && "Unknown topology");
- return TOP_UNKNOWN;
- }
-};
-
-
/*
* Draw vertex arrays, with optional indexing, optional instancing.
*/
{
struct swr_context *ctx = swr_context(pipe);
+ if (!info->count_from_stream_output && !info->indirect &&
+ !info->primitive_restart &&
+ !u_trim_pipe_prim(info->mode, (unsigned*)&info->count))
+ return;
+
if (!swr_check_render_cond(pipe))
return;
}
struct swr_vertex_element_state *velems = ctx->velems;
- if (!velems->fsFunc
- || (velems->fsState.cutIndex != info->restart_index)
- || (velems->fsState.bEnableCutIndex != info->primitive_restart)) {
-
- velems->fsState.cutIndex = info->restart_index;
- velems->fsState.bEnableCutIndex = info->primitive_restart;
-
- /* Create Fetch Shader */
+ velems->fsState.cutIndex = info->restart_index;
+ velems->fsState.bEnableCutIndex = info->primitive_restart;
+ velems->fsState.bPartialVertexBuffer = (info->min_index > 0);
+
+ swr_jit_fetch_key key;
+ swr_generate_fetch_key(key, velems);
+ auto search = velems->map.find(key);
+ if (search != velems->map.end()) {
+ velems->fsFunc = search->second;
+ } else {
HANDLE hJitMgr = swr_screen(ctx->pipe.screen)->hJitMgr;
velems->fsFunc = JitCompileFetch(hJitMgr, velems->fsState);
debug_printf("fetch shader %p\n", velems->fsFunc);
assert(velems->fsFunc && "Error: FetchShader = NULL");
+
+ velems->map.insert(std::make_pair(key, velems->fsFunc));
}
SwrSetFetchFunc(ctx->swrContext, velems->fsFunc);
feState.provokingVertex = {2, 1, 2};
}
- switch (info->mode) {
+ enum pipe_prim_type topology;
+ if (ctx->gs)
+ topology = (pipe_prim_type)ctx->gs->info.base.properties[TGSI_PROPERTY_GS_OUTPUT_PRIM];
+ else
+ topology = info->mode;
+
+ switch (topology) {
case PIPE_PRIM_TRIANGLE_FAN:
feState.topologyProvokingVertex = feState.provokingVertex.triFan;
break;
feState.bEnableCutIndex = info->primitive_restart;
SwrSetFrontendState(ctx->swrContext, &feState);
- if (info->indexed)
+ if (info->index_size)
SwrDrawIndexedInstanced(ctx->swrContext,
swr_convert_prim_topology(info->mode),
info->count,
if (renderTarget->pBaseAddress) {
swr_update_draw_context(ctx);
SWR_RECT full_rect =
- {0, 0, (int32_t)renderTarget->width, (int32_t)renderTarget->height};
+ {0, 0,
+ (int32_t)u_minify(renderTarget->width, renderTarget->lod),
+ (int32_t)u_minify(renderTarget->height, renderTarget->lod)};
SwrStoreTiles(ctx->swrContext,
1 << attachment,
post_tile_state,