GL_ARB_ES3_1_compatibility DONE (nvc0, radeonsi)
GL_ARB_clip_control DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe, swr)
GL_ARB_conditional_render_inverted DONE (i965, nv50, nvc0, r600, radeonsi, llvmpipe, softpipe, swr)
- GL_ARB_cull_distance DONE (i965, nv50, nvc0, llvmpipe, softpipe)
+ GL_ARB_cull_distance DONE (i965, nv50, nvc0, llvmpipe, softpipe, swr)
GL_ARB_derivative_control DONE (i965, nv50, nvc0, r600, radeonsi)
GL_ARB_direct_state_access DONE (all drivers)
GL_ARB_get_texture_sub_image DONE (all drivers)
#include "swr_state.h"
#include "swr_screen.h"
+static unsigned
+locate_linkage(ubyte name, ubyte index, struct tgsi_shader_info *info);
+
bool operator==(const swr_jit_fs_key &lhs, const swr_jit_fs_key &rhs)
{
return !memcmp(&lhs, &rhs, sizeof(lhs));
{
memset(&key, 0, sizeof(key));
+ key.clip_plane_mask =
+ swr_vs->info.base.clipdist_writemask ?
+ swr_vs->info.base.clipdist_writemask & ctx->rasterizer->clip_plane_enable :
+ ctx->rasterizer->clip_plane_enable;
+
swr_generate_sampler_key(swr_vs->info, ctx, PIPE_SHADER_VERTEX, key);
}
}
}
+ if (ctx->rasterizer->clip_plane_enable ||
+ swr_vs->info.base.culldist_writemask) {
+ unsigned clip_mask = ctx->rasterizer->clip_plane_enable;
+
+ unsigned cv = 0;
+ if (swr_vs->info.base.writes_clipvertex) {
+ cv = 1 + locate_linkage(TGSI_SEMANTIC_CLIPVERTEX, 0,
+ &swr_vs->info.base);
+ } else {
+ for (int i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
+ if (swr_vs->info.base.output_semantic_name[i] == TGSI_SEMANTIC_POSITION &&
+ swr_vs->info.base.output_semantic_index[i] == 0) {
+ cv = i;
+ break;
+ }
+ }
+ }
+ LLVMValueRef cx = LLVMBuildLoad(gallivm->builder, outputs[cv][0], "");
+ LLVMValueRef cy = LLVMBuildLoad(gallivm->builder, outputs[cv][1], "");
+ LLVMValueRef cz = LLVMBuildLoad(gallivm->builder, outputs[cv][2], "");
+ LLVMValueRef cw = LLVMBuildLoad(gallivm->builder, outputs[cv][3], "");
+
+ for (unsigned val = 0; val < PIPE_MAX_CLIP_PLANES; val++) {
+ // clip distance overrides user clip planes
+ if ((swr_vs->info.base.clipdist_writemask & clip_mask & (1 << val)) ||
+ ((swr_vs->info.base.culldist_writemask << swr_vs->info.base.num_written_clipdistance) & (1 << val))) {
+ unsigned cv = 1 + locate_linkage(TGSI_SEMANTIC_CLIPDIST, val < 4 ? 0 : 1,
+ &swr_vs->info.base);
+ if (val < 4) {
+ LLVMValueRef dist = LLVMBuildLoad(gallivm->builder, outputs[cv][val], "");
+ STORE(unwrap(dist), vtxOutput, {0, 0, VERTEX_CLIPCULL_DIST_LO_SLOT, val});
+ } else {
+ LLVMValueRef dist = LLVMBuildLoad(gallivm->builder, outputs[cv][val - 4], "");
+ STORE(unwrap(dist), vtxOutput, {0, 0, VERTEX_CLIPCULL_DIST_HI_SLOT, val - 4});
+ }
+ continue;
+ }
+
+ if (!(clip_mask & (1 << val)))
+ continue;
+
+ Value *px = LOAD(GEP(hPrivateData, {0, swr_draw_context_userClipPlanes, val, 0}));
+ Value *py = LOAD(GEP(hPrivateData, {0, swr_draw_context_userClipPlanes, val, 1}));
+ Value *pz = LOAD(GEP(hPrivateData, {0, swr_draw_context_userClipPlanes, val, 2}));
+ Value *pw = LOAD(GEP(hPrivateData, {0, swr_draw_context_userClipPlanes, val, 3}));
+ Value *dist = FADD(FMUL(unwrap(cx), VBROADCAST(px)),
+ FADD(FMUL(unwrap(cy), VBROADCAST(py)),
+ FADD(FMUL(unwrap(cz), VBROADCAST(pz)),
+ FMUL(unwrap(cw), VBROADCAST(pw)))));
+
+ if (val < 4)
+ STORE(dist, vtxOutput, {0, 0, VERTEX_CLIPCULL_DIST_LO_SLOT, val});
+ else
+ STORE(dist, vtxOutput, {0, 0, VERTEX_CLIPCULL_DIST_HI_SLOT, val - 4});
+ }
+ }
+
RET_VOID();
gallivm_verify_function(gallivm, wrap(pFunction));
}
/* Raster state */
- if (ctx->dirty & (SWR_NEW_RASTERIZER | SWR_NEW_FRAMEBUFFER)) {
+ if (ctx->dirty & (SWR_NEW_RASTERIZER |
+ SWR_NEW_VS | // clipping
+ SWR_NEW_FRAMEBUFFER)) {
pipe_rasterizer_state *rasterizer = ctx->rasterizer;
pipe_framebuffer_state *fb = &ctx->framebuffer;
rastState->depthClipEnable = rasterizer->depth_clip;
+ rastState->clipDistanceMask =
+ ctx->vs->info.base.num_written_clipdistance ?
+ ctx->vs->info.base.clipdist_writemask & rasterizer->clip_plane_enable :
+ rasterizer->clip_plane_enable;
+
+ rastState->cullDistanceMask =
+ ctx->vs->info.base.culldist_writemask << ctx->vs->info.base.num_written_clipdistance;
+
SwrSetRastState(ctx->swrContext, rastState);
}
/* VertexShader */
if (ctx->dirty & (SWR_NEW_VS |
+ SWR_NEW_RASTERIZER | // for clip planes
SWR_NEW_SAMPLER |
SWR_NEW_SAMPLER_VIEW |
SWR_NEW_FRAMEBUFFER)) {
}
}
+ if (ctx->dirty & SWR_NEW_CLIP) {
+ // shader exporting clip distances overrides all user clip planes
+ if (ctx->rasterizer->clip_plane_enable &&
+ !ctx->vs->info.base.num_written_clipdistance)
+ {
+ swr_draw_context *pDC = &ctx->swrDC;
+ memcpy(pDC->userClipPlanes,
+ ctx->clip.ucp,
+ sizeof(pDC->userClipPlanes));
+ }
+ }
+
uint32_t linkage = ctx->vs->linkageMask;
if (ctx->rasterizer->sprite_coord_enable)
linkage |= (1 << ctx->vs->info.base.num_outputs);