#include "util/u_format.h"
#include "util/u_half.h"
#include "vc5_context.h"
-#define V3D_VERSION 33
#include "broadcom/common/v3d_macros.h"
#include "broadcom/cle/v3dx_pack.h"
#include "broadcom/compiler/v3d_compiler.h"
}
}
+#if V3D_VERSION < 40
static uint32_t
translate_swizzle(unsigned char pipe_swizzle)
{
emit_one_texture(vc5, stage_tex, i);
}
}
+#endif /* V3D_VERSION < 40 */
static uint32_t
translate_colormask(struct vc5_context *vc5, uint32_t colormask, int rt)
return (~colormask) & 0xf;
}
+static void
+emit_rt_blend(struct vc5_context *vc5, struct vc5_job *job,
+ struct pipe_blend_state *blend, int rt)
+{
+ cl_emit(&job->bcl, BLEND_CONFIG, config) {
+ struct pipe_rt_blend_state *rtblend = &blend->rt[rt];
+
+#if V3D_VERSION >= 40
+ config.render_target_mask = 1 << rt;
+#else
+ assert(rt == 0);
+#endif
+
+ config.colour_blend_mode = rtblend->rgb_func;
+ config.colour_blend_dst_factor =
+ vc5_factor(rtblend->rgb_dst_factor,
+ vc5->blend_dst_alpha_one);
+ config.colour_blend_src_factor =
+ vc5_factor(rtblend->rgb_src_factor,
+ vc5->blend_dst_alpha_one);
+
+ config.alpha_blend_mode = rtblend->alpha_func;
+ config.alpha_blend_dst_factor =
+ vc5_factor(rtblend->alpha_dst_factor,
+ vc5->blend_dst_alpha_one);
+ config.alpha_blend_src_factor =
+ vc5_factor(rtblend->alpha_src_factor,
+ vc5->blend_dst_alpha_one);
+ }
+}
+
void
-vc5_emit_state(struct pipe_context *pctx)
+v3dX(emit_state)(struct pipe_context *pctx)
{
struct vc5_context *vc5 = vc5_context(pctx);
struct vc5_job *job = vc5->job;
if (vc5->dirty & VC5_DIRTY_BLEND && vc5->blend->rt[0].blend_enable) {
struct pipe_blend_state *blend = vc5->blend;
- cl_emit(&job->bcl, BLEND_CONFIG, config) {
- struct pipe_rt_blend_state *rtblend = &blend->rt[0];
-
- config.colour_blend_mode = rtblend->rgb_func;
- config.colour_blend_dst_factor =
- vc5_factor(rtblend->rgb_dst_factor,
- vc5->blend_dst_alpha_one);
- config.colour_blend_src_factor =
- vc5_factor(rtblend->rgb_src_factor,
- vc5->blend_dst_alpha_one);
-
- config.alpha_blend_mode = rtblend->alpha_func;
- config.alpha_blend_dst_factor =
- vc5_factor(rtblend->alpha_dst_factor,
- vc5->blend_dst_alpha_one);
- config.alpha_blend_src_factor =
- vc5_factor(rtblend->alpha_src_factor,
- vc5->blend_dst_alpha_one);
+ if (blend->independent_blend_enable) {
+ for (int i = 0; i < VC5_MAX_DRAW_BUFFERS; i++)
+ emit_rt_blend(vc5, job, blend, i);
+ } else {
+ emit_rt_blend(vc5, job, blend, 0);
}
}
}
}
+#if V3D_VERSION < 40
+ /* Pre-4.x, we have texture state that depends on both the sampler and
+ * the view, so we merge them together at draw time.
+ */
if (vc5->dirty & VC5_DIRTY_FRAGTEX)
emit_textures(vc5, &vc5->fragtex);
if (vc5->dirty & VC5_DIRTY_VERTTEX)
emit_textures(vc5, &vc5->verttex);
+#endif
if (vc5->dirty & VC5_DIRTY_FLAT_SHADE_FLAGS) {
bool emitted_any = false;
struct vc5_streamout_stateobj *so = &vc5->streamout;
if (so->num_targets) {
+#if V3D_VERSION >= 40
+ cl_emit(&job->bcl, TRANSFORM_FEEDBACK_SPECS, tfe) {
+ tfe.number_of_16_bit_output_data_specs_following =
+ vc5->prog.bind_vs->num_tf_specs;
+ tfe.enable =
+ (vc5->prog.bind_vs->num_tf_specs != 0 &&
+ vc5->active_queries);
+ };
+#else /* V3D_VERSION < 40 */
cl_emit(&job->bcl, TRANSFORM_FEEDBACK_ENABLE, tfe) {
tfe.number_of_32_bit_output_buffer_address_following =
so->num_targets;
tfe.number_of_16_bit_output_data_specs_following =
vc5->prog.bind_vs->num_tf_specs;
};
-
+#endif /* V3D_VERSION < 40 */
for (int i = 0; i < vc5->prog.bind_vs->num_tf_specs; i++) {
cl_emit_prepacked(&job->bcl,
&vc5->prog.bind_vs->tf_specs[i]);
struct vc5_resource *rsc =
vc5_resource(target->buffer);
+#if V3D_VERSION >= 40
+ cl_emit(&job->bcl, TRANSFORM_FEEDBACK_BUFFER, output) {
+ output.buffer_address =
+ cl_address(rsc->bo,
+ target->buffer_offset);
+ output.buffer_size_in_32_bit_words =
+ target->buffer_size >> 2;
+ output.buffer_number = i;
+ }
+#else /* V3D_VERSION < 40 */
cl_emit(&job->bcl, TRANSFORM_FEEDBACK_OUTPUT_ADDRESS, output) {
output.address =
cl_address(rsc->bo,
target->buffer_offset);
};
-
+#endif /* V3D_VERSION < 40 */
vc5_job_add_write_resource(vc5->job,
target->buffer);
/* XXX: buffer_size? */