X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Ffreedreno%2Fa2xx%2Ffd2_emit.c;h=a787b71e379ae8af99faf663918efaaa650a32fb;hb=d1d2b13518c190cf6db45dfb45b07f1246769767;hp=fe2750ba10b30d44c51cfad62b67c302c04e0c5a;hpb=df37902e346e0fc8e7db4cecb6f2dbd6aa370adb;p=mesa.git diff --git a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c index fe2750ba10b..a787b71e379 100644 --- a/src/gallium/drivers/freedreno/a2xx/fd2_emit.c +++ b/src/gallium/drivers/freedreno/a2xx/fd2_emit.c @@ -125,8 +125,9 @@ emit_texture(struct fd_ringbuffer *ring, struct fd_context *ctx, { unsigned const_idx = fd2_get_const_idx(ctx, tex, samp_id); static const struct fd2_sampler_stateobj dummy_sampler = {}; + static const struct fd2_pipe_sampler_view dummy_view = {}; const struct fd2_sampler_stateobj *sampler; - struct fd2_pipe_sampler_view *view; + const struct fd2_pipe_sampler_view *view; if (emitted & (1 << const_idx)) return 0; @@ -134,13 +135,19 @@ emit_texture(struct fd_ringbuffer *ring, struct fd_context *ctx, sampler = tex->samplers[samp_id] ? fd2_sampler_stateobj(tex->samplers[samp_id]) : &dummy_sampler; - view = fd2_pipe_sampler_view(tex->textures[samp_id]); + view = tex->textures[samp_id] ? + fd2_pipe_sampler_view(tex->textures[samp_id]) : + &dummy_view; OUT_PKT3(ring, CP_SET_CONSTANT, 7); OUT_RING(ring, 0x00010000 + (0x6 * const_idx)); OUT_RING(ring, sampler->tex0 | view->tex0); - OUT_RELOC(ring, fd_resource(view->base.texture)->bo, 0, view->fmt, 0); + if (view->base.texture) + OUT_RELOC(ring, fd_resource(view->base.texture)->bo, 0, view->fmt, 0); + else + OUT_RING(ring, 0); + OUT_RING(ring, view->tex2); OUT_RING(ring, sampler->tex3 | view->tex3); OUT_RING(ring, sampler->tex4); @@ -182,7 +189,7 @@ fd2_emit_vertex_bufs(struct fd_ringbuffer *ring, uint32_t val, } void -fd2_emit_state(struct fd_context *ctx, const uint32_t dirty) +fd2_emit_state(struct fd_context *ctx, const enum fd_dirty_3d_state dirty) { struct fd2_blend_stateobj *blend = fd2_blend_stateobj(ctx->blend); struct fd2_zsa_stateobj *zsa = fd2_zsa_stateobj(ctx->zsa); @@ -217,7 +224,7 @@ fd2_emit_state(struct fd_context *ctx, const uint32_t dirty) OUT_RING(ring, zsa->rb_alpha_ref); } - if (dirty & (FD_DIRTY_RASTERIZER | FD_DIRTY_FRAMEBUFFER)) { + if (ctx->rasterizer && dirty & FD_DIRTY_RASTERIZER) { struct fd2_rasterizer_stateobj *rasterizer = fd2_rasterizer_stateobj(ctx->rasterizer); OUT_PKT3(ring, CP_SET_CONSTANT, 3); @@ -284,7 +291,7 @@ fd2_emit_state(struct fd_context *ctx, const uint32_t dirty) fd2_program_emit(ring, &ctx->prog); } - if (dirty & (FD_DIRTY_PROG | FD_DIRTY_CONSTBUF)) { + if (dirty & (FD_DIRTY_PROG | FD_DIRTY_CONST)) { emit_constants(ring, VS_CONST_BASE * 4, &ctx->constbuf[PIPE_SHADER_VERTEX], (dirty & FD_DIRTY_PROG) ? ctx->prog.vp : NULL); @@ -299,17 +306,32 @@ fd2_emit_state(struct fd_context *ctx, const uint32_t dirty) OUT_RING(ring, zsa->rb_colorcontrol | blend->rb_colorcontrol); } - if (dirty & FD_DIRTY_BLEND) { + if (dirty & (FD_DIRTY_BLEND | FD_DIRTY_FRAMEBUFFER)) { + enum pipe_format format = + pipe_surface_format(ctx->batch->framebuffer.cbufs[0]); + bool has_alpha = util_format_has_alpha(format); + OUT_PKT3(ring, CP_SET_CONSTANT, 2); OUT_RING(ring, CP_REG(REG_A2XX_RB_BLEND_CONTROL)); - OUT_RING(ring, blend->rb_blendcontrol); + OUT_RING(ring, blend->rb_blendcontrol_alpha | + COND(has_alpha, blend->rb_blendcontrol_rgb) | + COND(!has_alpha, blend->rb_blendcontrol_no_alpha_rgb)); OUT_PKT3(ring, CP_SET_CONSTANT, 2); OUT_RING(ring, CP_REG(REG_A2XX_RB_COLOR_MASK)); OUT_RING(ring, blend->rb_colormask); } - if (dirty & (FD_DIRTY_VERTTEX | FD_DIRTY_FRAGTEX | FD_DIRTY_PROG)) + if (dirty & FD_DIRTY_BLEND_COLOR) { + OUT_PKT3(ring, CP_SET_CONSTANT, 5); + OUT_RING(ring, CP_REG(REG_A2XX_RB_BLEND_RED)); + OUT_RING(ring, float_to_ubyte(ctx->blend_color.color[0])); + OUT_RING(ring, float_to_ubyte(ctx->blend_color.color[1])); + OUT_RING(ring, float_to_ubyte(ctx->blend_color.color[2])); + OUT_RING(ring, float_to_ubyte(ctx->blend_color.color[3])); + } + + if (dirty & (FD_DIRTY_TEX | FD_DIRTY_PROG)) emit_textures(ring, ctx); }