Commit 81b7e2d0 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

Begin generating blend descriptors from Gallium

parent 0ad180d2
...@@ -284,6 +284,64 @@ trans_emit_vt_framebuffer(struct panfrost_context *ctx) ...@@ -284,6 +284,64 @@ trans_emit_vt_framebuffer(struct panfrost_context *ctx)
ctx->payload_tiler.framebuffer = framebuffer_1_p; ctx->payload_tiler.framebuffer = framebuffer_1_p;
} }
static bool
trans_make_fixed_blend_part(unsigned func, unsigned src_factor, unsigned dst_factor, unsigned *out)
{
struct mali_blend_mode part = { 0 };
/* Make sure that the blend function is representible with negate flags */
if (func == PIPE_BLEND_ADD) {
/* Default, no modifiers needed */
} else if (func == PIPE_BLEND_SUBTRACT)
part.negate_dest = true;
else if (func == PIPE_BLEND_REVERSE_SUBTRACT)
part.negate_source = true;
else
return false;
/* Write out mode */
memcpy(out, &part, sizeof(part));
return true;
}
/* Create the descriptor for a fixed blend mode given the corresponding Gallium
* state, if possible. Return true and write out the blend descriptor into
* blend_equation. If it is not possible with the fixed function
* representating, return false to handle degenerate cases with a blend shader
*/
static bool
trans_make_fixed_blend_mode(struct pipe_rt_blend_state *blend, struct mali_blend_equation *out)
{
unsigned rgb_mode, alpha_mode;
printf("Hi\n");
if (!trans_make_fixed_blend_part(
blend->rgb_func, blend->rgb_src_factor, blend->rgb_dst_factor,
&rgb_mode))
return false;
printf("A\n");
if (!trans_make_fixed_blend_part(
blend->alpha_func, blend->alpha_src_factor, blend->alpha_dst_factor,
&alpha_mode))
return false;
printf("RGB: 0x%X\n", rgb_mode);
printf("Alpha: 0x%X\n", alpha_mode);
out->rgb_mode = /* rgb_mode */ 0x122;
out->alpha_mode = alpha_mode;
/* Gallium and Mali represent colour masks identically. XXX: Is this future proof? */
out->color_mask = blend->colormask;
return true;
}
void void
trans_default_shader_backend(struct panfrost_context *ctx) trans_default_shader_backend(struct panfrost_context *ctx)
{ {
...@@ -316,6 +374,21 @@ trans_default_shader_backend(struct panfrost_context *ctx) ...@@ -316,6 +374,21 @@ trans_default_shader_backend(struct panfrost_context *ctx)
}, },
}; };
struct pipe_rt_blend_state default_blend = {
.rgb_func = PIPE_BLEND_ADD,
.rgb_src_factor = PIPE_BLENDFACTOR_ONE,
.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO,
.alpha_func = PIPE_BLEND_ADD,
.alpha_src_factor = PIPE_BLENDFACTOR_ONE,
.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO,
.colormask = PIPE_MASK_RGBA
};
if (!trans_make_fixed_blend_mode(&default_blend, &shader.blend_equation))
printf("ERROR: Default shader backend must not trigger blend shader\n");
memcpy(&ctx->fragment_shader_core, &shader, sizeof(shader)); memcpy(&ctx->fragment_shader_core, &shader, sizeof(shader));
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment