diff options
author | Tim Rowley <[email protected]> | 2017-06-29 14:03:43 -0500 |
---|---|---|
committer | Tim Rowley <[email protected]> | 2017-07-11 13:38:20 -0500 |
commit | 50cd222116b40e4df2462cb25a92960d557c9144 (patch) | |
tree | d80f494a6d0fdd90069cd3901ef6c9a14246daf1 /src/gallium/drivers | |
parent | 27c5568de3674ec95f02816a06b13180bad0838b (diff) |
swr: switch to using SwrGetInterface api table
Use the SWR rasterizer API through the table returned from
SwrGetInterface rather than referencing the functions directly.
This will allow us to move to a model of having the driver dynamically
load the appropriate swr architecture library.
Reviewed-by: Bruce Cherniak <[email protected]>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/swr/swr_clear.cpp | 6 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_context.cpp | 19 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_context.h | 5 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_draw.cpp | 46 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_fence.cpp | 2 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_memory.h | 6 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_query.cpp | 8 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_scratch.cpp | 2 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_screen.cpp | 3 | ||||
-rw-r--r-- | src/gallium/drivers/swr/swr_state.cpp | 40 |
10 files changed, 72 insertions, 65 deletions
diff --git a/src/gallium/drivers/swr/swr_clear.cpp b/src/gallium/drivers/swr/swr_clear.cpp index 3a35805a7ac..233432ee34a 100644 --- a/src/gallium/drivers/swr/swr_clear.cpp +++ b/src/gallium/drivers/swr/swr_clear.cpp @@ -78,9 +78,9 @@ swr_clear(struct pipe_context *pipe, for (unsigned i = 0; i < layers; ++i) { swr_update_draw_context(ctx); - SwrClearRenderTarget(ctx->swrContext, clearMask, i, - color->f, depth, stencil, - clear_rect); + ctx->api.pfnSwrClearRenderTarget(ctx->swrContext, clearMask, i, + color->f, depth, stencil, + clear_rect); // Mask out the attachments that are out of layers. if (fb->zsbuf && diff --git a/src/gallium/drivers/swr/swr_context.cpp b/src/gallium/drivers/swr/swr_context.cpp index f2d971a22e8..9648278c691 100644 --- a/src/gallium/drivers/swr/swr_context.cpp +++ b/src/gallium/drivers/swr/swr_context.cpp @@ -311,8 +311,8 @@ swr_blit(struct pipe_context *pipe, const struct pipe_blit_info *blit_info) } if (ctx->active_queries) { - SwrEnableStatsFE(ctx->swrContext, FALSE); - SwrEnableStatsBE(ctx->swrContext, FALSE); + ctx->api.pfnSwrEnableStatsFE(ctx->swrContext, FALSE); + ctx->api.pfnSwrEnableStatsBE(ctx->swrContext, FALSE); } util_blitter_save_vertex_buffer_slot(ctx->blitter, ctx->vertex_buffer); @@ -349,8 +349,8 @@ swr_blit(struct pipe_context *pipe, const struct pipe_blit_info *blit_info) util_blitter_blit(ctx->blitter, &info); if (ctx->active_queries) { - SwrEnableStatsFE(ctx->swrContext, TRUE); - SwrEnableStatsBE(ctx->swrContext, TRUE); + ctx->api.pfnSwrEnableStatsFE(ctx->swrContext, TRUE); + ctx->api.pfnSwrEnableStatsBE(ctx->swrContext, TRUE); } } @@ -383,10 +383,10 @@ swr_destroy(struct pipe_context *pipe) /* Idle core after destroying buffer resources, but before deleting * context. Destroying resources has potentially called StoreTiles.*/ - SwrWaitForIdle(ctx->swrContext); + ctx->api.pfnSwrWaitForIdle(ctx->swrContext); if (ctx->swrContext) - SwrDestroyContext(ctx->swrContext); + ctx->api.pfnSwrDestroyContext(ctx->swrContext); delete ctx->blendJIT; @@ -467,6 +467,9 @@ swr_create_context(struct pipe_screen *p_screen, void *priv, unsigned flags) AlignedMalloc(sizeof(struct swr_context), KNOB_SIMD_BYTES); memset(ctx, 0, sizeof(struct swr_context)); + SwrGetInterface(ctx->api); + ctx->swrDC.pAPI = &ctx->api; + ctx->blendJIT = new std::unordered_map<BLEND_COMPILE_STATE, PFN_BLEND_JIT_FUNC>; @@ -478,9 +481,9 @@ swr_create_context(struct pipe_screen *p_screen, void *priv, unsigned flags) createInfo.pfnClearTile = swr_StoreHotTileClear; createInfo.pfnUpdateStats = swr_UpdateStats; createInfo.pfnUpdateStatsFE = swr_UpdateStatsFE; - ctx->swrContext = SwrCreateContext(&createInfo); + ctx->swrContext = ctx->api.pfnSwrCreateContext(&createInfo); - SwrInit(); + ctx->api.pfnSwrInit(); if (ctx->swrContext == NULL) goto fail; diff --git a/src/gallium/drivers/swr/swr_context.h b/src/gallium/drivers/swr/swr_context.h index 3ff4bf3e2fa..753cbf3115a 100644 --- a/src/gallium/drivers/swr/swr_context.h +++ b/src/gallium/drivers/swr/swr_context.h @@ -102,6 +102,7 @@ struct swr_draw_context { SWR_SURFACE_STATE renderTargets[SWR_NUM_ATTACHMENTS]; struct swr_query_result *pStats; // @llvm_struct + SWR_INTERFACE *pAPI; // @llvm_struct - Needed for the swr_memory callbacks }; /* gen_llvm_types FINI */ @@ -169,6 +170,8 @@ struct swr_context { struct swr_draw_context swrDC; unsigned dirty; /**< Mask of SWR_NEW_x flags */ + + SWR_INTERFACE api; }; static INLINE struct swr_context * @@ -182,7 +185,7 @@ swr_update_draw_context(struct swr_context *ctx, struct swr_query_result *pqr = nullptr) { swr_draw_context *pDC = - (swr_draw_context *)SwrGetPrivateContextState(ctx->swrContext); + (swr_draw_context *)ctx->api.pfnSwrGetPrivateContextState(ctx->swrContext); if (pqr) ctx->swrDC.pStats = pqr; memcpy(pDC, &ctx->swrDC, sizeof(swr_draw_context)); diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp index f26b8e873c1..eae4b572df3 100644 --- a/src/gallium/drivers/swr/swr_draw.cpp +++ b/src/gallium/drivers/swr/swr_draw.cpp @@ -100,7 +100,7 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) assert(ctx->vs->soFunc[info->mode] && "Error: SoShader = NULL"); } - SwrSetSoFunc(ctx->swrContext, ctx->vs->soFunc[info->mode], 0); + ctx->api.pfnSwrSetSoFunc(ctx->swrContext, ctx->vs->soFunc[info->mode], 0); } struct swr_vertex_element_state *velems = ctx->velems; @@ -123,7 +123,7 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) velems->map.insert(std::make_pair(key, velems->fsFunc)); } - SwrSetFetchFunc(ctx->swrContext, velems->fsFunc); + ctx->api.pfnSwrSetFetchFunc(ctx->swrContext, velems->fsFunc); /* Set up frontend state * XXX setup provokingVertex & topologyProvokingVertex */ @@ -171,23 +171,23 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) } feState.bEnableCutIndex = info->primitive_restart; - SwrSetFrontendState(ctx->swrContext, &feState); + ctx->api.pfnSwrSetFrontendState(ctx->swrContext, &feState); if (info->index_size) - SwrDrawIndexedInstanced(ctx->swrContext, - swr_convert_prim_topology(info->mode), - info->count, - info->instance_count, - info->start, - info->index_bias, - info->start_instance); + ctx->api.pfnSwrDrawIndexedInstanced(ctx->swrContext, + swr_convert_prim_topology(info->mode), + info->count, + info->instance_count, + info->start, + info->index_bias, + info->start_instance); else - SwrDrawInstanced(ctx->swrContext, - swr_convert_prim_topology(info->mode), - info->count, - info->instance_count, - info->start, - info->start_instance); + ctx->api.pfnSwrDrawInstanced(ctx->swrContext, + swr_convert_prim_topology(info->mode), + info->count, + info->instance_count, + info->start, + info->start_instance); } @@ -235,9 +235,9 @@ swr_invalidate_render_target(struct pipe_context *pipe, swr_update_draw_context(ctx); SWR_RECT full_rect = {0, 0, (int32_t)width, (int32_t)height}; - SwrInvalidateTiles(ctx->swrContext, - 1 << attachment, - full_rect); + ctx->api.pfnSwrInvalidateTiles(ctx->swrContext, + 1 << attachment, + full_rect); } @@ -260,10 +260,10 @@ swr_store_render_target(struct pipe_context *pipe, {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, - full_rect); + ctx->api.pfnSwrStoreTiles(ctx->swrContext, + 1 << attachment, + post_tile_state, + full_rect); } } diff --git a/src/gallium/drivers/swr/swr_fence.cpp b/src/gallium/drivers/swr/swr_fence.cpp index c73bbbf2708..abf1d0c69c8 100644 --- a/src/gallium/drivers/swr/swr_fence.cpp +++ b/src/gallium/drivers/swr/swr_fence.cpp @@ -59,7 +59,7 @@ swr_fence_submit(struct swr_context *ctx, struct pipe_fence_handle *fh) fence->write++; fence->pending = TRUE; - SwrSync(ctx->swrContext, swr_fence_cb, (uint64_t)fence, fence->write, 0); + ctx->api.pfnSwrSync(ctx->swrContext, swr_fence_cb, (uint64_t)fence, fence->write, 0); } /* diff --git a/src/gallium/drivers/swr/swr_memory.h b/src/gallium/drivers/swr/swr_memory.h index ec68df311a4..fc5561680cb 100644 --- a/src/gallium/drivers/swr/swr_memory.h +++ b/src/gallium/drivers/swr/swr_memory.h @@ -34,7 +34,7 @@ swr_LoadHotTile(HANDLE hPrivateContext, swr_draw_context *pDC = (swr_draw_context*)hPrivateContext; SWR_SURFACE_STATE *pSrcSurface = &pDC->renderTargets[renderTargetIndex]; - SwrLoadHotTile(pSrcSurface, dstFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pDstHotTile); + pDC->pAPI->pfnSwrLoadHotTile(pSrcSurface, dstFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pDstHotTile); } INLINE void @@ -48,7 +48,7 @@ swr_StoreHotTile(HANDLE hPrivateContext, swr_draw_context *pDC = (swr_draw_context*)hPrivateContext; SWR_SURFACE_STATE *pDstSurface = &pDC->renderTargets[renderTargetIndex]; - SwrStoreHotTileToSurface(pDstSurface, srcFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pSrcHotTile); + pDC->pAPI->pfnSwrStoreHotTileToSurface(pDstSurface, srcFormat, renderTargetIndex, x, y, renderTargetArrayIndex, pSrcHotTile); } INLINE void @@ -63,5 +63,5 @@ swr_StoreHotTileClear(HANDLE hPrivateContext, swr_draw_context *pDC = (swr_draw_context*)hPrivateContext; SWR_SURFACE_STATE *pDstSurface = &pDC->renderTargets[renderTargetIndex]; - SwrStoreHotTileClear(pDstSurface, renderTargetIndex, x, y, renderTargetArrayIndex, pClearColor); + pDC->pAPI->pfnSwrStoreHotTileClear(pDstSurface, renderTargetIndex, x, y, renderTargetArrayIndex, pClearColor); } diff --git a/src/gallium/drivers/swr/swr_query.cpp b/src/gallium/drivers/swr/swr_query.cpp index e097790892d..4c14c5206b0 100644 --- a/src/gallium/drivers/swr/swr_query.cpp +++ b/src/gallium/drivers/swr/swr_query.cpp @@ -180,8 +180,8 @@ swr_begin_query(struct pipe_context *pipe, struct pipe_query *q) /* Only change stat collection if there are no active queries */ if (ctx->active_queries == 0) { - SwrEnableStatsFE(ctx->swrContext, TRUE); - SwrEnableStatsBE(ctx->swrContext, TRUE); + ctx->api.pfnSwrEnableStatsFE(ctx->swrContext, TRUE); + ctx->api.pfnSwrEnableStatsBE(ctx->swrContext, TRUE); } ctx->active_queries++; break; @@ -217,8 +217,8 @@ swr_end_query(struct pipe_context *pipe, struct pipe_query *q) /* Only change stat collection if there are no active queries */ ctx->active_queries--; if (ctx->active_queries == 0) { - SwrEnableStatsFE(ctx->swrContext, FALSE); - SwrEnableStatsBE(ctx->swrContext, FALSE); + ctx->api.pfnSwrEnableStatsFE(ctx->swrContext, FALSE); + ctx->api.pfnSwrEnableStatsBE(ctx->swrContext, FALSE); } break; diff --git a/src/gallium/drivers/swr/swr_scratch.cpp b/src/gallium/drivers/swr/swr_scratch.cpp index db095dea7e3..6a9ab10ee2f 100644 --- a/src/gallium/drivers/swr/swr_scratch.cpp +++ b/src/gallium/drivers/swr/swr_scratch.cpp @@ -41,7 +41,7 @@ swr_copy_to_scratch_space(struct swr_context *ctx, if (size >= 2048) { /* XXX TODO create KNOB_ for this */ /* Use per draw SwrAllocDrawContextMemory for larger copies */ - ptr = SwrAllocDrawContextMemory(ctx->swrContext, size, 4); + ptr = ctx->api.pfnSwrAllocDrawContextMemory(ctx->swrContext, size, 4); } else { /* Allocate enough so that MAX_DRAWS_IN_FLIGHT sets fit. */ unsigned int max_size_in_flight = size * KNOB_MAX_DRAWS_IN_FLIGHT; diff --git a/src/gallium/drivers/swr/swr_screen.cpp b/src/gallium/drivers/swr/swr_screen.cpp index 53b5dadec9f..ccaba263d6e 100644 --- a/src/gallium/drivers/swr/swr_screen.cpp +++ b/src/gallium/drivers/swr/swr_screen.cpp @@ -1016,11 +1016,12 @@ swr_flush_frontbuffer(struct pipe_screen *p_screen, 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 resolved into resolve_target at flush with store_resource */ diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 45c9c213e5b..4eef60681a7 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -1165,12 +1165,12 @@ swr_update_derived(struct pipe_context *pipe, rastState->cullDistanceMask = ctx->vs->info.base.culldist_writemask << ctx->vs->info.base.num_written_clipdistance; - SwrSetRastState(ctx->swrContext, rastState); + ctx->api.pfnSwrSetRastState(ctx->swrContext, rastState); } /* Scissor */ if (ctx->dirty & SWR_NEW_SCISSOR) { - SwrSetScissorRects(ctx->swrContext, 1, &ctx->swr_scissor); + ctx->api.pfnSwrSetScissorRects(ctx->swrContext, 1, &ctx->swr_scissor); } /* Viewport */ @@ -1210,7 +1210,7 @@ swr_update_derived(struct pipe_context *pipe, vp->width = std::min(vp->width, (float)fb->width - vp->x); vp->height = std::min(vp->height, (float)fb->height - vp->y); - SwrSetViewports(ctx->swrContext, 1, vp, vpm); + ctx->api.pfnSwrSetViewports(ctx->swrContext, 1, vp, vpm); } /* Set vertex & index buffers @@ -1285,7 +1285,7 @@ swr_update_derived(struct pipe_context *pipe, swrVertexBuffers[i].partialInboundsSize = partial_inbounds; } - SwrSetVertexBuffers( + ctx->api.pfnSwrSetVertexBuffers( ctx->swrContext, ctx->num_vertex_buffers, swrVertexBuffers); /* index buffer, if required (info passed in by swr_draw_vbo) */ @@ -1324,7 +1324,7 @@ swr_update_derived(struct pipe_context *pipe, swrIndexBuffer.pIndices = p_data; swrIndexBuffer.size = size; - SwrSetIndexBuffer(ctx->swrContext, &swrIndexBuffer); + ctx->api.pfnSwrSetIndexBuffer(ctx->swrContext, &swrIndexBuffer); } struct swr_vertex_element_state *velems = ctx->velems; @@ -1349,7 +1349,7 @@ swr_update_derived(struct pipe_context *pipe, } else { func = swr_compile_gs(ctx, key); } - SwrSetGsFunc(ctx->swrContext, func); + ctx->api.pfnSwrSetGsFunc(ctx->swrContext, func); /* JIT sampler state */ if (ctx->dirty & SWR_NEW_SAMPLER) { @@ -1367,11 +1367,11 @@ swr_update_derived(struct pipe_context *pipe, ctx->swrDC.texturesGS); } - SwrSetGsState(ctx->swrContext, &ctx->gs->gsState); + ctx->api.pfnSwrSetGsState(ctx->swrContext, &ctx->gs->gsState); } else { SWR_GS_STATE state = { 0 }; - SwrSetGsState(ctx->swrContext, &state); - SwrSetGsFunc(ctx->swrContext, NULL); + ctx->api.pfnSwrSetGsState(ctx->swrContext, &state); + ctx->api.pfnSwrSetGsFunc(ctx->swrContext, NULL); } } @@ -1390,7 +1390,7 @@ swr_update_derived(struct pipe_context *pipe, } else { func = swr_compile_vs(ctx, key); } - SwrSetVertexFunc(ctx->swrContext, func); + ctx->api.pfnSwrSetVertexFunc(ctx->swrContext, func); /* JIT sampler state */ if (ctx->dirty & SWR_NEW_SAMPLER) { @@ -1478,7 +1478,7 @@ swr_update_derived(struct pipe_context *pipe, psState.barycentricsMask = barycentricsMask; psState.usesUAV = false; // XXX psState.forceEarlyZ = false; - SwrSetPixelShaderState(ctx->swrContext, &psState); + ctx->api.pfnSwrSetPixelShaderState(ctx->swrContext, &psState); /* JIT sampler state */ if (ctx->dirty & (SWR_NEW_SAMPLER | @@ -1567,12 +1567,12 @@ swr_update_derived(struct pipe_context *pipe, depthStencilState.depthTestEnable = depth->enabled; depthStencilState.depthTestFunc = swr_convert_depth_func(depth->func); depthStencilState.depthWriteEnable = depth->writemask; - SwrSetDepthStencilState(ctx->swrContext, &depthStencilState); + ctx->api.pfnSwrSetDepthStencilState(ctx->swrContext, &depthStencilState); depthBoundsState.depthBoundsTestEnable = depth->bounds_test; depthBoundsState.depthBoundsTestMinValue = depth->bounds_min; depthBoundsState.depthBoundsTestMaxValue = depth->bounds_max; - SwrSetDepthBoundsState(ctx->swrContext, &depthBoundsState); + ctx->api.pfnSwrSetDepthBoundsState(ctx->swrContext, &depthBoundsState); } /* Blend State */ @@ -1601,7 +1601,7 @@ swr_update_derived(struct pipe_context *pipe, blendState.renderTarget[0].writeDisableGreen = 1; blendState.renderTarget[0].writeDisableBlue = 1; blendState.renderTarget[0].writeDisableAlpha = 1; - SwrSetBlendFunc(ctx->swrContext, 0, NULL); + ctx->api.pfnSwrSetBlendFunc(ctx->swrContext, 0, NULL); } else for (int target = 0; @@ -1633,7 +1633,7 @@ swr_update_derived(struct pipe_context *pipe, if (compileState.blendState.blendEnable == false && compileState.blendState.logicOpEnable == false && ctx->depth_stencil->alpha.enabled == 0) { - SwrSetBlendFunc(ctx->swrContext, target, NULL); + ctx->api.pfnSwrSetBlendFunc(ctx->swrContext, target, NULL); continue; } @@ -1669,10 +1669,10 @@ swr_update_derived(struct pipe_context *pipe, ctx->blendJIT->insert(std::make_pair(compileState, func)); } - SwrSetBlendFunc(ctx->swrContext, target, func); + ctx->api.pfnSwrSetBlendFunc(ctx->swrContext, target, func); } - SwrSetBlendState(ctx->swrContext, &blendState); + ctx->api.pfnSwrSetBlendState(ctx->swrContext, &blendState); } if (ctx->dirty & SWR_NEW_STIPPLE) { @@ -1682,7 +1682,7 @@ swr_update_derived(struct pipe_context *pipe, if (ctx->dirty & (SWR_NEW_VS | SWR_NEW_SO | SWR_NEW_RASTERIZER)) { ctx->vs->soState.rasterizerDisable = ctx->rasterizer->rasterizer_discard; - SwrSetSoState(ctx->swrContext, &ctx->vs->soState); + ctx->api.pfnSwrSetSoState(ctx->swrContext, &ctx->vs->soState); pipe_stream_output_info *stream_output = &ctx->vs->pipe.stream_output; @@ -1698,7 +1698,7 @@ swr_update_derived(struct pipe_context *pipe, buffer.pitch = stream_output->stride[i]; buffer.streamOffset = 0; - SwrSetSoBuffers(ctx->swrContext, &buffer, i); + ctx->api.pfnSwrSetSoBuffers(ctx->swrContext, &buffer, i); } } @@ -1750,7 +1750,7 @@ swr_update_derived(struct pipe_context *pipe, backendState.readViewportArrayIndex = pLastFE->writes_viewport_index; backendState.vertexAttribOffset = VERTEX_ATTRIB_START_SLOT; // TODO: optimize - SwrSetBackendState(ctx->swrContext, &backendState); + ctx->api.pfnSwrSetBackendState(ctx->swrContext, &backendState); /* Ensure that any in-progress attachment change StoreTiles finish */ if (swr_is_fence_pending(screen->flush_fence)) |