zink: handle point sprite
this needs custom yinvert handling and also prim mode detection, which gallium can't do on its own Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9115>
This commit is contained in:

committed by
Marge Bot

parent
b9676976d0
commit
cf8ca77be1
@@ -469,6 +469,12 @@ zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, struct z
|
||||
nir = nir_shader_clone(NULL, zs->nir);
|
||||
NIR_PASS_V(nir, lower_dual_blend);
|
||||
}
|
||||
if (zink_fs_key(key)->coord_replace_bits) {
|
||||
if (nir == zs->nir)
|
||||
nir = nir_shader_clone(NULL, zs->nir);
|
||||
NIR_PASS_V(nir, nir_lower_texcoord_replace, zink_fs_key(key)->coord_replace_bits,
|
||||
false, zink_fs_key(key)->coord_replace_yinvert);
|
||||
}
|
||||
}
|
||||
struct spirv_shader *spirv = nir_to_spirv(nir, streamout, shader_slot_map, shader_slots_reserved);
|
||||
assert(spirv);
|
||||
|
@@ -664,6 +664,11 @@ zink_draw_vbo(struct pipe_context *pctx,
|
||||
if (drawid_broken != ctx->drawid_broken)
|
||||
ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_VERTEX);
|
||||
ctx->gfx_pipeline_state.vertices_per_patch = dinfo->vertices_per_patch;
|
||||
if (ctx->rast_state->base.point_quad_rasterization &&
|
||||
ctx->gfx_prim_mode != dinfo->mode) {
|
||||
if (ctx->gfx_prim_mode == PIPE_PRIM_POINTS || dinfo->mode == PIPE_PRIM_POINTS)
|
||||
ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_FRAGMENT);
|
||||
}
|
||||
ctx->gfx_prim_mode = dinfo->mode;
|
||||
struct zink_gfx_program *gfx_program = get_gfx_program(ctx);
|
||||
if (!gfx_program)
|
||||
|
@@ -246,6 +246,11 @@ shader_key_fs_gen(struct zink_context *ctx, struct zink_shader *zs,
|
||||
fs_key->force_dual_color_blend = screen->driconf.dual_color_blend_by_location &&
|
||||
ctx->gfx_pipeline_state.blend_state->dual_src_blend &&
|
||||
ctx->gfx_pipeline_state.blend_state->attachments[1].blendEnable;
|
||||
if (((shaders[PIPE_SHADER_GEOMETRY] && shaders[PIPE_SHADER_GEOMETRY]->nir->info.gs.output_primitive == GL_POINTS) ||
|
||||
ctx->gfx_prim_mode == PIPE_PRIM_POINTS) && ctx->rast_state->base.point_quad_rasterization && ctx->rast_state->base.sprite_coord_enable) {
|
||||
fs_key->coord_replace_bits = ctx->rast_state->base.sprite_coord_enable;
|
||||
fs_key->coord_replace_yinvert = !!ctx->rast_state->base.sprite_coord_mode;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -264,6 +264,9 @@ zink_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
||||
case PIPE_CAP_TEXTURE_MULTISAMPLE:
|
||||
return 1;
|
||||
|
||||
case PIPE_CAP_POINT_SPRITE:
|
||||
return 1;
|
||||
|
||||
case PIPE_CAP_SAMPLE_SHADING:
|
||||
return screen->info.feats.features.sampleRateShading;
|
||||
|
||||
|
@@ -35,6 +35,8 @@ struct zink_vs_key {
|
||||
|
||||
struct zink_fs_key {
|
||||
unsigned shader_id;
|
||||
uint8_t coord_replace_bits;
|
||||
bool coord_replace_yinvert;
|
||||
//bool flat_shade;
|
||||
bool samples;
|
||||
bool force_dual_color_blend;
|
||||
|
@@ -468,6 +468,7 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
|
||||
{
|
||||
struct zink_context *ctx = zink_context(pctx);
|
||||
bool clip_halfz = ctx->rast_state ? ctx->rast_state->base.clip_halfz : false;
|
||||
bool point_quad_rasterization = ctx->rast_state ? ctx->rast_state->base.point_quad_rasterization : false;
|
||||
ctx->rast_state = cso;
|
||||
|
||||
if (ctx->rast_state) {
|
||||
@@ -483,6 +484,8 @@ zink_bind_rasterizer_state(struct pipe_context *pctx, void *cso)
|
||||
ctx->line_width = ctx->rast_state->line_width;
|
||||
ctx->gfx_pipeline_state.dirty = true;
|
||||
}
|
||||
if (ctx->rast_state->base.point_quad_rasterization != point_quad_rasterization)
|
||||
ctx->dirty_shader_stages |= BITFIELD_BIT(PIPE_SHADER_FRAGMENT);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user