t.polygon_list_size = panfrost_tiler_full_size(
width, height, t.hierarchy_mask, hierarchy);
- /* Sanity check */
-
if (vertex_count) {
- struct panfrost_bo *tiler_heap;
-
- tiler_heap = panfrost_batch_get_tiler_heap(batch);
t.polygon_list = panfrost_batch_get_polygon_list(batch,
header_size +
t.polygon_list_size);
- /* Allow the entire tiler heap */
- t.heap_start = tiler_heap->gpu;
- t.heap_end = tiler_heap->gpu + tiler_heap->size;
+ t.heap_start = device->tiler_heap->gpu;
+ t.heap_end = device->tiler_heap->gpu + device->tiler_heap->size;
} else {
struct panfrost_bo *tiler_dummy;
* fragment jobs.
*/
struct panfrost_batch *batch = panfrost_get_fresh_batch_for_fbo(ctx);
-
- panfrost_batch_add_fbo_bos(batch);
panfrost_batch_clear(batch, buffers, color, depth, stencil);
}
-/* Reset per-frame context, called on context initialisation as well as after
- * flushing a frame */
-
-void
-panfrost_invalidate_frame(struct panfrost_context *ctx)
-{
- /* TODO: When does this need to be handled? */
- ctx->active_queries = true;
-}
-
bool
panfrost_writes_point_size(struct panfrost_context *ctx)
{
return vs->writes_point_size && ctx->active_prim == PIPE_PRIM_POINTS;
}
-void
-panfrost_vertex_state_upd_attr_offs(struct panfrost_context *ctx,
- struct mali_vertex_tiler_postfix *vertex_postfix)
-{
- if (!ctx->vertex)
- return;
-
- struct panfrost_vertex_state *so = ctx->vertex;
-
- /* Fixup offsets for the second pass. Recall that the hardware
- * calculates attribute addresses as:
- *
- * addr = base + (stride * vtx) + src_offset;
- *
- * However, on Mali, base must be aligned to 64-bytes, so we
- * instead let:
- *
- * base' = base & ~63 = base - (base & 63)
- *
- * To compensate when using base' (see emit_vertex_data), we have
- * to adjust src_offset by the masked off piece:
- *
- * addr' = base' + (stride * vtx) + (src_offset + (base & 63))
- * = base - (base & 63) + (stride * vtx) + src_offset + (base & 63)
- * = base + (stride * vtx) + src_offset
- * = addr;
- *
- * QED.
- */
-
- unsigned start = vertex_postfix->offset_start;
-
- for (unsigned i = 0; i < so->num_elements; ++i) {
- unsigned vbi = so->pipe[i].vertex_buffer_index;
- struct pipe_vertex_buffer *buf = &ctx->vertex_buffers[vbi];
-
- /* Adjust by the masked off bits of the offset. Make sure we
- * read src_offset from so->hw (which is not GPU visible)
- * rather than target (which is) due to caching effects */
-
- unsigned src_offset = so->pipe[i].src_offset;
-
- /* BOs aligned to 4k so guaranteed aligned to 64 */
- src_offset += (buf->buffer_offset & 63);
-
- /* Also, somewhat obscurely per-instance data needs to be
- * offset in response to a delayed start in an indexed draw */
-
- if (so->pipe[i].instance_divisor && ctx->instance_count > 1 && start)
- src_offset -= buf->stride * start;
-
- so->hw[i].src_offset = src_offset;
- }
-}
-
-/* Compute number of UBOs active (more specifically, compute the highest UBO
- * number addressable -- if there are gaps, include them in the count anyway).
- * We always include UBO #0 in the count, since we *need* uniforms enabled for
- * sysvals. */
-
-unsigned
-panfrost_ubo_count(struct panfrost_context *ctx, enum pipe_shader_type stage)
-{
- unsigned mask = ctx->constant_buffer[stage].enabled_mask | 1;
- return 32 - __builtin_clz(mask);
-}
-
/* The entire frame is in memory -- send it off to the kernel! */
void
panfrost_flush_all_batches(ctx, 0);
}
-#define DEFINE_CASE(c) case PIPE_PRIM_##c: return MALI_##c;
+#define DEFINE_CASE(c) case PIPE_PRIM_##c: return MALI_DRAW_MODE_##c;
static int
-g2m_draw_mode(enum pipe_prim_type mode)
+pan_draw_mode(enum pipe_prim_type mode)
{
switch (mode) {
DEFINE_CASE(POINTS);
/* Check if we're scissoring at all */
- if (!(ctx->rasterizer && ctx->rasterizer->base.scissor))
+ if (!ctx->rasterizer->base.scissor)
return false;
return (ss->minx == ss->maxx) || (ss->miny == ss->maxy);
count = u_stream_outputs_for_vertices(ctx->active_prim,
ctx->vertex_count);
- ctx->streamout.offsets[i] += count;
+ pan_so_target(ctx->streamout.targets[i])->offset += count;
+ }
+}
+
+static inline void
+pan_emit_draw_descs(struct panfrost_batch *batch,
+ struct MALI_DRAW *d, enum pipe_shader_type st)
+{
+ d->offset_start = batch->ctx->offset_start;
+ d->instances = batch->ctx->instance_count > 1 ?
+ batch->ctx->padded_count : 1;
+
+ d->uniform_buffers = panfrost_emit_const_buf(batch, st, &d->push_uniforms);
+ d->textures = panfrost_emit_texture_descriptors(batch, st);
+ d->samplers = panfrost_emit_sampler_descriptors(batch, st);
+}
+
+static enum mali_index_type
+panfrost_translate_index_size(unsigned size)
+{
+ switch (size) {
+ case 1: return MALI_INDEX_TYPE_UINT8;
+ case 2: return MALI_INDEX_TYPE_UINT16;
+ case 4: return MALI_INDEX_TYPE_UINT32;
+ default: unreachable("Invalid index size");
}
}
const struct pipe_draw_info *info)
{
struct panfrost_context *ctx = pan_context(pipe);
+ struct panfrost_device *device = pan_device(ctx->base.screen);
/* First of all, check the scissor to see if anything is drawn at all.
* If it's not, we drop the draw (mostly a conformance issue;
assert(ctx->rasterizer != NULL);
if (!(ctx->draw_modes & (1 << mode))) {
- if (mode == PIPE_PRIM_QUADS && info->count == 4 && !ctx->rasterizer->base.flatshade) {
- mode = PIPE_PRIM_TRIANGLE_FAN;
- } else {
- if (info->count < 4) {
- /* Degenerate case? */
- return;
- }
-
- util_primconvert_save_rasterizer_state(ctx->primconvert, &ctx->rasterizer->base);
- util_primconvert_draw_vbo(ctx->primconvert, info);
+ if (info->count < 4) {
+ /* Degenerate case? */
return;
}
+
+ util_primconvert_save_rasterizer_state(ctx->primconvert, &ctx->rasterizer->base);
+ util_primconvert_draw_vbo(ctx->primconvert, info);
+ return;
}
- /* Now that we have a guaranteed terminating path, find the job.
- * Assignment commented out to prevent unused warning */
+ /* Now that we have a guaranteed terminating path, find the job. */
struct panfrost_batch *batch = panfrost_get_batch_for_fbo(ctx);
-
- panfrost_batch_add_fbo_bos(batch);
panfrost_batch_set_requirements(batch);
/* Take into account a negative bias */
ctx->instance_count = info->instance_count;
ctx->active_prim = info->mode;
- struct mali_vertex_tiler_prefix vertex_prefix, tiler_prefix;
- struct mali_vertex_tiler_postfix vertex_postfix, tiler_postfix;
+ struct mali_vertex_tiler_prefix vertex_prefix = { 0 }, tiler_prefix = { 0 };
+ struct mali_draw_packed vertex_postfix, tiler_postfix;
+ struct mali_primitive_packed primitive;
+ struct mali_invocation_packed invocation;
union midgard_primitive_size primitive_size;
- unsigned vertex_count;
+ unsigned vertex_count = ctx->vertex_count;
- panfrost_vt_init(ctx, PIPE_SHADER_VERTEX, &vertex_prefix, &vertex_postfix);
- panfrost_vt_init(ctx, PIPE_SHADER_FRAGMENT, &tiler_prefix, &tiler_postfix);
+ mali_ptr shared_mem = (device->quirks & IS_BIFROST) ?
+ panfrost_vt_emit_shared_memory(batch) :
+ panfrost_batch_reserve_framebuffer(batch);
- panfrost_vt_set_draw_info(ctx, info, g2m_draw_mode(mode),
- &vertex_postfix, &tiler_prefix,
- &tiler_postfix, &vertex_count,
- &ctx->padded_count);
+ struct pipe_rasterizer_state *rast = &ctx->rasterizer->base;
+ unsigned min_index = 0, max_index = 0;
- panfrost_statistics_record(ctx, info);
+ pan_pack(&primitive, PRIMITIVE, cfg) {
+ cfg.draw_mode = pan_draw_mode(mode);
+ cfg.point_size_array = panfrost_writes_point_size(ctx);
+ cfg.first_provoking_vertex = rast->flatshade_first;
+ cfg.primitive_restart = info->primitive_restart;
+ cfg.unknown_3 = 6;
+
+ if (info->index_size) {
+ cfg.index_type = panfrost_translate_index_size(info->index_size);
+ cfg.indices = panfrost_get_index_buffer_bounded(ctx, info,
+ &min_index, &max_index);
+
+ /* Use the corresponding values */
+ vertex_count = max_index - min_index + 1;
+ ctx->offset_start = min_index + info->index_bias;
+
+ cfg.base_vertex_offset = -min_index;
+ cfg.index_count = info->count;
+ } else {
+ ctx->offset_start = info->start;
+ cfg.index_count = info->count_from_stream_output ?
+ pan_so_target(info->count_from_stream_output)->offset :
+ ctx->vertex_count;
+ }
+ }
- /* Dispatch "compute jobs" for the vertex/tiler pair as (1,
- * vertex_count, 1) */
+ vertex_prefix.primitive.opaque[0] = (5) << 26; /* XXX */
+ memcpy(&tiler_prefix.primitive, &primitive, sizeof(primitive));
- panfrost_pack_work_groups_fused(&vertex_prefix, &tiler_prefix,
+ /* Encode the padded vertex count */
+
+ if (info->instance_count > 1)
+ ctx->padded_count = panfrost_padded_vertex_count(vertex_count);
+ else
+ ctx->padded_count = vertex_count;
+
+ panfrost_statistics_record(ctx, info);
+
+ panfrost_pack_work_groups_compute(&invocation,
1, vertex_count, info->instance_count,
- 1, 1, 1);
+ 1, 1, 1, true);
+
+ vertex_prefix.invocation = invocation;
+ tiler_prefix.invocation = invocation;
/* Emit all sort of descriptors. */
- panfrost_emit_vertex_data(batch, &vertex_postfix);
+ mali_ptr varyings = 0, vs_vary = 0, fs_vary = 0, pos = 0, psiz = 0;
+
panfrost_emit_varying_descriptor(batch,
ctx->padded_count *
ctx->instance_count,
- &vertex_postfix, &tiler_postfix,
- &primitive_size);
- panfrost_emit_shader_meta(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
- panfrost_emit_shader_meta(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
- panfrost_emit_vertex_attr_meta(batch, &vertex_postfix);
- panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
- panfrost_emit_sampler_descriptors(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
- panfrost_emit_texture_descriptors(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
- panfrost_emit_texture_descriptors(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
- panfrost_emit_const_buf(batch, PIPE_SHADER_VERTEX, &vertex_postfix);
- panfrost_emit_const_buf(batch, PIPE_SHADER_FRAGMENT, &tiler_postfix);
- panfrost_emit_viewport(batch, &tiler_postfix);
-
- panfrost_vt_update_primitive_size(ctx, &tiler_prefix, &primitive_size);
+ &vs_vary, &fs_vary, &varyings,
+ &pos, &psiz);
+
+ pan_pack(&vertex_postfix, DRAW, cfg) {
+ cfg.unknown_1 = (device->quirks & IS_BIFROST) ? 0x2 : 0x6;
+ cfg.state = panfrost_emit_compute_shader_meta(batch, PIPE_SHADER_VERTEX);
+ cfg.attributes = panfrost_emit_vertex_data(batch, &cfg.attribute_buffers);
+ cfg.varyings = vs_vary;
+ cfg.varying_buffers = varyings;
+ cfg.shared = shared_mem;
+ pan_emit_draw_descs(batch, &cfg, PIPE_SHADER_VERTEX);
+ }
+
+ pan_pack(&tiler_postfix, DRAW, cfg) {
+ cfg.unknown_1 = (device->quirks & IS_BIFROST) ? 0x3 : 0x7;
+ cfg.front_face_ccw = rast->front_ccw;
+ cfg.cull_front_face = rast->cull_face & PIPE_FACE_FRONT;
+ cfg.cull_back_face = rast->cull_face & PIPE_FACE_BACK;
+ cfg.position = pos;
+ cfg.state = panfrost_emit_frag_shader_meta(batch);
+ cfg.viewport = panfrost_emit_viewport(batch);
+ cfg.varyings = fs_vary;
+ cfg.varying_buffers = varyings;
+ cfg.shared = shared_mem;
+
+ pan_emit_draw_descs(batch, &cfg, PIPE_SHADER_FRAGMENT);
+
+ if (ctx->occlusion_query) {
+ cfg.occlusion_query = MALI_OCCLUSION_MODE_PREDICATE;
+ cfg.occlusion = ctx->occlusion_query->bo->gpu;
+ panfrost_batch_add_bo(ctx->batch, ctx->occlusion_query->bo,
+ PAN_BO_ACCESS_SHARED |
+ PAN_BO_ACCESS_RW |
+ PAN_BO_ACCESS_FRAGMENT);
+ }
+ }
+
+ primitive_size.pointer = psiz;
+ panfrost_vt_update_primitive_size(ctx, info->mode == PIPE_PRIM_POINTS, &primitive_size);
/* Fire off the draw itself */
panfrost_emit_vertex_tiler_jobs(batch, &vertex_prefix, &vertex_postfix,
so->base = *cso;
+ /* Gauranteed with the core GL call, so don't expose ARB_polygon_offset */
+ assert(cso->offset_clamp == 0.0);
+
return so;
}
void *hwcso)
{
struct panfrost_context *ctx = pan_context(pctx);
-
ctx->rasterizer = hwcso;
-
- if (!hwcso)
- return;
-
- /* Gauranteed with the core GL call, so don't expose ARB_polygon_offset */
- assert(ctx->rasterizer->base.offset_clamp == 0.0);
-
- /* Point sprites are emulated */
-
- struct panfrost_shader_state *variant = panfrost_get_shader_state(ctx, PIPE_SHADER_FRAGMENT);
-
- if (ctx->rasterizer->base.sprite_coord_enable || (variant && variant->point_sprite_mask))
- ctx->base.bind_fs_state(&ctx->base, ctx->shader[PIPE_SHADER_FRAGMENT]);
}
static void *
memcpy(so->pipe, elements, sizeof(*elements) * num_elements);
for (int i = 0; i < num_elements; ++i) {
- so->hw[i].index = i;
-
enum pipe_format fmt = elements[i].src_format;
const struct util_format_description *desc = util_format_description(fmt);
- so->hw[i].unknown1 = 0x2;
-
+ unsigned swizzle = 0;
if (dev->quirks & HAS_SWIZZLES)
- so->hw[i].swizzle = panfrost_translate_swizzle_4(desc->swizzle);
+ swizzle = panfrost_translate_swizzle_4(desc->swizzle);
else
- so->hw[i].swizzle = panfrost_bifrost_swizzle(desc->nr_channels);
+ swizzle = panfrost_bifrost_swizzle(desc->nr_channels);
enum mali_format hw_format = panfrost_pipe_format_table[desc->format].hw;
- so->hw[i].format = hw_format;
+ so->formats[i] = (hw_format << 12) | swizzle;
assert(hw_format);
}
/* Let's also prepare vertex builtins */
- so->hw[PAN_VERTEX_ID].format = MALI_R32UI;
if (dev->quirks & HAS_SWIZZLES)
- so->hw[PAN_VERTEX_ID].swizzle = panfrost_get_default_swizzle(1);
+ so->formats[PAN_VERTEX_ID] = (MALI_R32UI << 12) | panfrost_get_default_swizzle(1);
else
- so->hw[PAN_VERTEX_ID].swizzle = panfrost_bifrost_swizzle(1);
+ so->formats[PAN_VERTEX_ID] = (MALI_R32UI << 12) | panfrost_bifrost_swizzle(1);
- so->hw[PAN_INSTANCE_ID].format = MALI_R32UI;
if (dev->quirks & HAS_SWIZZLES)
- so->hw[PAN_INSTANCE_ID].swizzle = panfrost_get_default_swizzle(1);
+ so->formats[PAN_INSTANCE_ID] = (MALI_R32UI << 12) | panfrost_get_default_swizzle(1);
else
- so->hw[PAN_INSTANCE_ID].swizzle = panfrost_bifrost_swizzle(1);
+ so->formats[PAN_INSTANCE_ID] = (MALI_R32UI << 12) | panfrost_bifrost_swizzle(1);
return so;
}
if (unlikely((dev->debug & PAN_DBG_PRECOMPILE) && cso->type == PIPE_SHADER_IR_NIR)) {
struct panfrost_context *ctx = pan_context(pctx);
- struct panfrost_shader_state state;
+ struct panfrost_shader_state state = { 0 };
uint64_t outputs_written;
panfrost_shader_compile(ctx, PIPE_SHADER_IR_NIR,
for (unsigned i = 0; i < cso->variant_count; ++i) {
struct panfrost_shader_state *shader_state = &cso->variants[i];
panfrost_bo_unreference(shader_state->bo);
+
+ if (shader_state->upload.rsrc)
+ pipe_resource_reference(&shader_state->upload.rsrc, NULL);
+
shader_state->bo = NULL;
}
free(cso->variants);
+
free(so);
}
so->base = *cso;
if (device->quirks & IS_BIFROST)
- panfrost_sampler_desc_init_bifrost(cso, &so->bifrost_hw);
+ panfrost_sampler_desc_init_bifrost(cso, (struct mali_bifrost_sampler_packed *) &so->hw);
else
- panfrost_sampler_desc_init(cso, &so->midgard_hw);
+ panfrost_sampler_desc_init(cso, &so->hw);
return so;
}
enum pipe_shader_type type)
{
struct panfrost_device *dev = pan_device(ctx->base.screen);
- struct pipe_rasterizer_state *rasterizer = &ctx->rasterizer->base;
- struct pipe_alpha_state *alpha = &ctx->depth_stencil->alpha;
-
- bool is_fragment = (type == PIPE_SHADER_FRAGMENT);
-
- if (is_fragment && (alpha->enabled || variant->alpha_state.enabled)) {
- /* Make sure enable state is at least the same */
- if (alpha->enabled != variant->alpha_state.enabled) {
- return false;
- }
-
- /* Check that the contents of the test are the same */
- bool same_func = alpha->func == variant->alpha_state.func;
- bool same_ref = alpha->ref_value == variant->alpha_state.ref_value;
-
- if (!(same_func && same_ref)) {
- return false;
- }
- }
if (variant->outputs_read) {
struct pipe_framebuffer_state *fb = &ctx->pipe_framebuffer;
}
}
- /* Point sprites TODO on bifrost, always pass */
- if (is_fragment && rasterizer && (rasterizer->sprite_coord_enable |
- variant->point_sprite_mask)
- && !(dev->quirks & IS_BIFROST)) {
- /* Ensure the same varyings are turned to point sprites */
- if (rasterizer->sprite_coord_enable != variant->point_sprite_mask)
- return false;
-
- /* Ensure the orientation is correct */
- bool upper_left =
- rasterizer->sprite_coord_mode ==
- PIPE_SPRITE_COORD_UPPER_LEFT;
-
- if (variant->point_sprite_upper_left != upper_left)
- return false;
- }
-
/* Otherwise, we're good to go */
return true;
}
&variants->variants[variant];
if (type == PIPE_SHADER_FRAGMENT) {
- v->alpha_state = ctx->depth_stencil->alpha;
-
struct pipe_framebuffer_state *fb = &ctx->pipe_framebuffer;
for (unsigned i = 0; i < fb->nr_cbufs; ++i) {
enum pipe_format fmt = PIPE_FORMAT_R8G8B8A8_UNORM;
v->rt_formats[i] = fmt;
}
-
- /* Point sprites are TODO on Bifrost */
- if (ctx->rasterizer && !(dev->quirks & IS_BIFROST)) {
- v->point_sprite_mask = ctx->rasterizer->base.sprite_coord_enable;
- v->point_sprite_upper_left =
- ctx->rasterizer->base.sprite_coord_mode ==
- PIPE_SPRITE_COORD_UPPER_LEFT;
- }
}
}
assert(texture->nr_samples <= 1);
}
- enum mali_texture_type type =
- panfrost_translate_texture_type(so->base.target);
+ enum mali_texture_dimension type =
+ panfrost_translate_texture_dimension(so->base.target);
if (device->quirks & IS_BIFROST) {
unsigned char composed_swizzle[4];
so->bo = panfrost_bo_create(device, size, 0);
- so->bifrost_descriptor = rzalloc(pctx, struct bifrost_texture_descriptor);
panfrost_new_texture_bifrost(
- so->bifrost_descriptor,
+ &so->bifrost_descriptor,
texture->width0, texture->height0,
depth, array_size,
format,
so->base.u.tex.last_layer,
texture->nr_samples,
type, prsrc->modifier);
- size += sizeof(struct mali_texture_descriptor);
+ size += MALI_MIDGARD_TEXTURE_LENGTH;
so->bo = panfrost_bo_create(device, size, 0);
pipe_resource_reference(&pview->texture, NULL);
panfrost_bo_unreference(view->bo);
- if (view->bifrost_descriptor)
- ralloc_free(view->bifrost_descriptor);
ralloc_free(view);
}
util_copy_framebuffer_state(&ctx->pipe_framebuffer, fb);
ctx->batch = NULL;
- panfrost_invalidate_frame(ctx);
/* We may need to generate a new variant if the fragment shader is
* keyed to the framebuffer format (due to EXT_framebuffer_fetch) */
ctx->base.bind_fs_state(&ctx->base, fs);
}
+static inline unsigned
+pan_pipe_to_stencil_op(enum pipe_stencil_op in)
+{
+ switch (in) {
+ case PIPE_STENCIL_OP_KEEP: return MALI_STENCIL_OP_KEEP;
+ case PIPE_STENCIL_OP_ZERO: return MALI_STENCIL_OP_ZERO;
+ case PIPE_STENCIL_OP_REPLACE: return MALI_STENCIL_OP_REPLACE;
+ case PIPE_STENCIL_OP_INCR: return MALI_STENCIL_OP_INCR_SAT;
+ case PIPE_STENCIL_OP_DECR: return MALI_STENCIL_OP_DECR_SAT;
+ case PIPE_STENCIL_OP_INCR_WRAP: return MALI_STENCIL_OP_INCR_WRAP;
+ case PIPE_STENCIL_OP_DECR_WRAP: return MALI_STENCIL_OP_DECR_WRAP;
+ case PIPE_STENCIL_OP_INVERT: return MALI_STENCIL_OP_INVERT;
+ default: unreachable("Invalid stencil op");
+ }
+}
+
+static inline void
+pan_pipe_to_stencil(const struct pipe_stencil_state *in, void *out)
+{
+ pan_pack(out, STENCIL, cfg) {
+ cfg.mask = in->valuemask;
+ cfg.compare_function = panfrost_translate_compare_func(in->func);
+ cfg.stencil_fail = pan_pipe_to_stencil_op(in->fail_op);
+ cfg.depth_fail = pan_pipe_to_stencil_op(in->zfail_op);
+ cfg.depth_pass = pan_pipe_to_stencil_op(in->zpass_op);
+ }
+}
+
static void *
panfrost_create_depth_stencil_state(struct pipe_context *pipe,
- const struct pipe_depth_stencil_alpha_state *depth_stencil)
+ const struct pipe_depth_stencil_alpha_state *zsa)
{
- return mem_dup(depth_stencil, sizeof(*depth_stencil));
+ struct panfrost_zsa_state *so = CALLOC_STRUCT(panfrost_zsa_state);
+ so->base = *zsa;
+
+ pan_pipe_to_stencil(&zsa->stencil[0], &so->stencil_front);
+ so->stencil_mask_front = zsa->stencil[0].writemask;
+
+ if (zsa->stencil[1].enabled) {
+ pan_pipe_to_stencil(&zsa->stencil[1], &so->stencil_back);
+ so->stencil_mask_back = zsa->stencil[1].writemask;
+ } else {
+ so->stencil_back = so->stencil_front;
+ so->stencil_mask_back = so->stencil_mask_front;
+ }
+
+ /* Alpha lowered by frontend */
+ assert(!zsa->alpha.enabled);
+
+ /* TODO: Bounds test should be easy */
+ assert(!zsa->depth.bounds_test);
+
+ return so;
}
static void
void *cso)
{
struct panfrost_context *ctx = pan_context(pipe);
- struct pipe_depth_stencil_alpha_state *depth_stencil = cso;
- ctx->depth_stencil = depth_stencil;
-
- if (!depth_stencil)
- return;
-
- /* Alpha does not exist in the hardware (it's not in ES3), so it's
- * emulated in the fragment shader */
-
- if (depth_stencil->alpha.enabled) {
- /* We need to trigger a new shader (maybe) */
- ctx->base.bind_fs_state(&ctx->base, ctx->shader[PIPE_SHADER_FRAGMENT]);
- }
-
- /* Bounds test not implemented */
- assert(!depth_stencil->depth.bounds_test);
+ ctx->depth_stencil = cso;
}
static void
util_unreference_framebuffer_state(&panfrost->pipe_framebuffer);
u_upload_destroy(pipe->stream_uploader);
+ u_upload_destroy(panfrost->state_uploader);
ralloc_free(pipe);
}
{
struct pipe_stream_output_target *target;
- target = rzalloc(pctx, struct pipe_stream_output_target);
+ target = &rzalloc(pctx, struct panfrost_streamout_target)->base;
if (!target)
return NULL;
for (unsigned i = 0; i < num_targets; i++) {
if (offsets[i] != -1)
- so->offsets[i] = offsets[i];
+ pan_so_target(targets[i])->offset = offsets[i];
pipe_so_target_reference(&so->targets[i], targets[i]);
}
gallium->stream_uploader = u_upload_create_default(gallium);
gallium->const_uploader = gallium->stream_uploader;
- assert(gallium->stream_uploader);
+
+ ctx->state_uploader = u_upload_create(gallium, 4096,
+ PIPE_BIND_CONSTANT_BUFFER, PIPE_USAGE_DYNAMIC, 0);
/* All of our GPUs support ES mode. Midgard supports additionally
* QUADS/QUAD_STRIPS/POLYGON. Bifrost supports just QUADS. */
/* Prepare for render! */
panfrost_batch_init(ctx);
- panfrost_invalidate_frame(ctx);
if (!(dev->quirks & IS_BIFROST)) {
for (unsigned c = 0; c < PIPE_MAX_COLOR_BUFS; ++c)
/* By default mask everything on */
ctx->sample_mask = ~0;
+ ctx->active_queries = true;
return gallium;
}