#include "util/u_string.h"
#include "util/u_memory.h"
#include "util/u_prim.h"
+#include "util/u_format.h"
#include "freedreno_state.h"
#include "freedreno_resource.h"
/* do binning pass first: */
.binning_pass = true,
.color_two_side = ctx->rasterizer ? ctx->rasterizer->light_twoside : false,
+ .alpha = util_format_is_alpha(pipe_surface_format(ctx->framebuffer.cbufs[0])),
// TODO set .half_precision based on render target format,
// ie. float16 and smaller use half, float32 use full..
.half_precision = !!(fd_mesa_debug & FD_DBG_FRAGHALF),
block->noutputs = j * 4;
}
+ /* for rendering to alpha format, we only need the .w component,
+ * and we need it to be in the .x position:
+ */
+ if (key.alpha) {
+ for (i = 0, j = 0; i < so->outputs_count; i++) {
+ unsigned name = sem2name(so->outputs[i].semantic);
+
+ /* move .w component to .x and discard others: */
+ if (name == TGSI_SEMANTIC_COLOR) {
+ block->outputs[(i*4)+0] = block->outputs[(i*4)+3];
+ block->outputs[(i*4)+1] = NULL;
+ block->outputs[(i*4)+2] = NULL;
+ block->outputs[(i*4)+3] = NULL;
+ }
+ }
+ }
+
/* at this point, we want the kill's in the outputs array too,
* so that they get scheduled (since they have no dst).. we've
* already ensured that the array is big enough in push_block():
if (shader->type == SHADER_VERTEX) {
key.color_two_side = false;
key.half_precision = false;
+ key.alpha = false;
}
for (v = shader->variants; v; v = v->next)
* in hw (two sided color), binning-pass vertex shader, etc.
*/
struct ir3_shader_key {
- /* vertex shader variant parameters: */
+ /*
+ * Vertex shader variant parameters:
+ */
unsigned binning_pass : 1;
- /* fragment shader variant parameters: */
+ /*
+ * Fragment shader variant parameters:
+ */
unsigned color_two_side : 1;
unsigned half_precision : 1;
+ /* For rendering to alpha, we need a bit of special handling
+ * since the hw always takes gl_FragColor starting from x
+ * component, rather than figuring out to take the w component.
+ * We could be more clever and generate variants for other
+ * render target formats (ie. luminance formats are xxx1), but
+ * let's start with this and see how it goes:
+ */
+ unsigned alpha : 1;
};
struct ir3_shader_variant {