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 &&
}
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);
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);
}
}
/* 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;
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>;
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;
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 */
struct swr_draw_context swrDC;
unsigned dirty; /**< Mask of SWR_NEW_x flags */
+
+ SWR_INTERFACE api;
};
static INLINE struct swr_context *
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));
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;
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 */
}
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);
}
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);
}
{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);
}
}
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);
}
/*
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
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
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);
}
/* 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;
/* 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;
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;
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 */
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 */
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
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) */
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;
} 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) {
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);
}
}
} 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) {
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 |
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 */
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;
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;
}
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) {
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;
buffer.pitch = stream_output->stride[i];
buffer.streamOffset = 0;
- SwrSetSoBuffers(ctx->swrContext, &buffer, i);
+ ctx->api.pfnSwrSetSoBuffers(ctx->swrContext, &buffer, i);
}
}
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))