Path: blob/21.2-virgl/src/gallium/drivers/freedreno/a5xx/fd5_draw.h
4574 views
/*1* Copyright (C) 2016 Rob Clark <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,19* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE20* SOFTWARE.21*22* Authors:23* Rob Clark <[email protected]>24*/2526#ifndef FD5_DRAW_H_27#define FD5_DRAW_H_2829#include "pipe/p_context.h"3031#include "freedreno_draw.h"3233#include "fd5_context.h"34#include "fd5_screen.h"3536/* some bits in common w/ a4xx: */37#include "a4xx/fd4_draw.h"3839void fd5_draw_init(struct pipe_context *pctx);4041static inline void42fd5_draw(struct fd_batch *batch, struct fd_ringbuffer *ring,43enum pc_di_primtype primtype, enum pc_di_vis_cull_mode vismode,44enum pc_di_src_sel src_sel, uint32_t count, uint32_t instances,45enum a4xx_index_size idx_type, uint32_t max_indices,46uint32_t idx_offset, struct pipe_resource *idx_buffer)47{48/* for debug after a lock up, write a unique counter value49* to scratch7 for each draw, to make it easier to match up50* register dumps to cmdstream. The combination of IB51* (scratch6) and DRAW is enough to "triangulate" the52* particular draw that caused lockup.53*/54emit_marker5(ring, 7);5556OUT_PKT7(ring, CP_DRAW_INDX_OFFSET, idx_buffer ? 7 : 3);57if (vismode == USE_VISIBILITY) {58/* leave vis mode blank for now, it will be patched up when59* we know if we are binning or not60*/61OUT_RINGP(ring, DRAW4(primtype, src_sel, idx_type, 0),62&batch->draw_patches);63} else {64OUT_RING(ring, DRAW4(primtype, src_sel, idx_type, vismode));65}66OUT_RING(ring, instances); /* NumInstances */67OUT_RING(ring, count); /* NumIndices */68if (idx_buffer) {69OUT_RING(ring, 0x0); /* XXX */70OUT_RELOC(ring, fd_resource(idx_buffer)->bo, idx_offset, 0, 0);71OUT_RING(ring, max_indices);72}7374emit_marker5(ring, 7);7576fd_reset_wfi(batch);77}7879static inline void80fd5_draw_emit(struct fd_batch *batch, struct fd_ringbuffer *ring,81enum pc_di_primtype primtype, enum pc_di_vis_cull_mode vismode,82const struct pipe_draw_info *info,83const struct pipe_draw_indirect_info *indirect,84const struct pipe_draw_start_count_bias *draw, unsigned index_offset)85{86struct pipe_resource *idx_buffer = NULL;87enum a4xx_index_size idx_type;88enum pc_di_src_sel src_sel;89uint32_t max_indices, idx_offset;9091if (indirect && indirect->buffer) {92struct fd_resource *ind = fd_resource(indirect->buffer);9394emit_marker5(ring, 7);9596if (info->index_size) {97struct pipe_resource *idx = info->index.resource;98max_indices = idx->width0 / info->index_size;99100OUT_PKT7(ring, CP_DRAW_INDX_INDIRECT, 6);101OUT_RINGP(ring,102DRAW4(primtype, DI_SRC_SEL_DMA,103fd4_size2indextype(info->index_size), 0),104&batch->draw_patches);105OUT_RELOC(ring, fd_resource(idx)->bo, index_offset, 0, 0);106OUT_RING(ring, A5XX_CP_DRAW_INDX_INDIRECT_3_MAX_INDICES(max_indices));107OUT_RELOC(ring, ind->bo, indirect->offset, 0, 0);108} else {109OUT_PKT7(ring, CP_DRAW_INDIRECT, 3);110OUT_RINGP(ring, DRAW4(primtype, DI_SRC_SEL_AUTO_INDEX, 0, 0),111&batch->draw_patches);112OUT_RELOC(ring, ind->bo, indirect->offset, 0, 0);113}114115emit_marker5(ring, 7);116fd_reset_wfi(batch);117118return;119}120121if (info->index_size) {122assert(!info->has_user_indices);123124idx_buffer = info->index.resource;125idx_type = fd4_size2indextype(info->index_size);126max_indices = idx_buffer->width0 / info->index_size;127idx_offset = index_offset + draw->start * info->index_size;128src_sel = DI_SRC_SEL_DMA;129} else {130idx_buffer = NULL;131idx_type = INDEX4_SIZE_32_BIT;132max_indices = 0;133idx_offset = 0;134src_sel = DI_SRC_SEL_AUTO_INDEX;135}136137fd5_draw(batch, ring, primtype, vismode, src_sel, draw->count,138info->instance_count, idx_type, max_indices, idx_offset,139idx_buffer);140}141142#endif /* FD5_DRAW_H_ */143144145