Lines Matching +full:render +full:- +full:max

40  * user-submitted CL and writing the validated copy out to the memory
55 /** Return the width in pixels of a 64-byte microtile. */
73 /** Return the height in pixels of a 64-byte microtile. */
91 * size_is_lt() - Returns whether a miplevel of the given size will
108 struct vc4_dev *vc4 = exec->dev; in vc4_use_bo()
112 if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4)) in vc4_use_bo()
115 if (hindex >= exec->bo_count) { in vc4_use_bo()
117 hindex, exec->bo_count); in vc4_use_bo()
120 obj = to_drm_gem_dma_obj(exec->bo[hindex]); in vc4_use_bo()
121 bo = to_vc4_bo(&obj->base); in vc4_use_bo()
123 if (bo->validated_shader) { in vc4_use_bo()
135 return vc4_use_bo(exec, exec->bo_index[gem_handles_packet_index]); in vc4_use_handle()
144 return (untrusted - 1 == exec->bin_u + pos); in validate_bin_pos()
167 struct vc4_dev *vc4 = exec->dev; in vc4_check_tex_size()
172 if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4)) in vc4_check_tex_size()
176 * (-2048,2047) offsets from the viewport center, so we should in vc4_check_tex_size()
177 * never have a render target larger than 4096. The texture in vc4_check_tex_size()
210 size + offset > fbo->base.size) { in vc4_check_tex_size()
214 size, offset, fbo->base.size); in vc4_check_tex_size()
224 if (!validate_bin_pos(exec, untrusted, exec->args->bin_cl_size - 1)) { in validate_flush()
226 return -EINVAL; in validate_flush()
228 exec->found_flush = true; in validate_flush()
236 if (exec->found_start_tile_binning_packet) { in validate_start_tile_binning()
238 return -EINVAL; in validate_start_tile_binning()
240 exec->found_start_tile_binning_packet = true; in validate_start_tile_binning()
242 if (!exec->found_tile_binning_mode_config_packet) { in validate_start_tile_binning()
244 return -EINVAL; in validate_start_tile_binning()
253 if (!validate_bin_pos(exec, untrusted, exec->args->bin_cl_size - 2)) { in validate_increment_semaphore()
256 return -EINVAL; in validate_increment_semaphore()
258 exec->found_increment_semaphore_packet = true; in validate_increment_semaphore()
274 if (exec->shader_state_count == 0) { in validate_indexed_prim_list()
276 return -EINVAL; in validate_indexed_prim_list()
278 shader_state = &exec->shader_state[exec->shader_state_count - 1]; in validate_indexed_prim_list()
280 if (max_index > shader_state->max_index) in validate_indexed_prim_list()
281 shader_state->max_index = max_index; in validate_indexed_prim_list()
285 return -EINVAL; in validate_indexed_prim_list()
287 exec->bin_dep_seqno = max(exec->bin_dep_seqno, in validate_indexed_prim_list()
288 to_vc4_bo(&ib->base)->write_seqno); in validate_indexed_prim_list()
290 if (offset > ib->base.size || in validate_indexed_prim_list()
291 (ib->base.size - offset) / index_size < length) { in validate_indexed_prim_list()
293 offset, length, index_size, ib->base.size); in validate_indexed_prim_list()
294 return -EINVAL; in validate_indexed_prim_list()
297 *(uint32_t *)(validated + 5) = ib->dma_addr + offset; in validate_indexed_prim_list()
311 if (exec->shader_state_count == 0) { in validate_gl_array_primitive()
313 return -EINVAL; in validate_gl_array_primitive()
315 shader_state = &exec->shader_state[exec->shader_state_count - 1]; in validate_gl_array_primitive()
319 return -EINVAL; in validate_gl_array_primitive()
321 max_index = length + base_index - 1; in validate_gl_array_primitive()
323 if (max_index > shader_state->max_index) in validate_gl_array_primitive()
324 shader_state->max_index = max_index; in validate_gl_array_primitive()
332 uint32_t i = exec->shader_state_count++; in validate_gl_shader_state()
334 if (i >= exec->shader_state_size) { in validate_gl_shader_state()
336 return -EINVAL; in validate_gl_shader_state()
339 exec->shader_state[i].addr = *(uint32_t *)untrusted; in validate_gl_shader_state()
340 exec->shader_state[i].max_index = 0; in validate_gl_shader_state()
342 if (exec->shader_state[i].addr & ~0xf) { in validate_gl_shader_state()
344 return -EINVAL; in validate_gl_shader_state()
347 *(uint32_t *)validated = (exec->shader_rec_p + in validate_gl_shader_state()
348 exec->shader_state[i].addr); in validate_gl_shader_state()
350 exec->shader_rec_p += in validate_gl_shader_state()
351 roundup(gl_shader_rec_size(exec->shader_state[i].addr), 16); in validate_gl_shader_state()
359 struct drm_device *dev = exec->exec_bo->base.dev; in validate_tile_binning_config()
366 if (exec->found_tile_binning_mode_config_packet) { in validate_tile_binning_config()
368 return -EINVAL; in validate_tile_binning_config()
370 exec->found_tile_binning_mode_config_packet = true; in validate_tile_binning_config()
372 exec->bin_tiles_x = *(uint8_t *)(untrusted + 12); in validate_tile_binning_config()
373 exec->bin_tiles_y = *(uint8_t *)(untrusted + 13); in validate_tile_binning_config()
374 tile_count = exec->bin_tiles_x * exec->bin_tiles_y; in validate_tile_binning_config()
377 if (exec->bin_tiles_x == 0 || in validate_tile_binning_config()
378 exec->bin_tiles_y == 0) { in validate_tile_binning_config()
380 exec->bin_tiles_x, exec->bin_tiles_y); in validate_tile_binning_config()
381 return -EINVAL; in validate_tile_binning_config()
387 return -EINVAL; in validate_tile_binning_config()
392 if (bin_slot != -EINTR && bin_slot != -ERESTARTSYS) { in validate_tile_binning_config()
402 exec->bin_slots |= BIT(bin_slot); in validate_tile_binning_config()
403 bin_addr = vc4->bin_bo->base.dma_addr + bin_slot * vc4->bin_alloc_size; in validate_tile_binning_config()
411 exec->tile_alloc_offset = bin_addr + roundup(tile_state_size, 4096); in validate_tile_binning_config()
423 *(uint32_t *)(validated + 0) = exec->tile_alloc_offset; in validate_tile_binning_config()
425 *(uint32_t *)(validated + 4) = (bin_addr + vc4->bin_alloc_size - in validate_tile_binning_config()
426 exec->tile_alloc_offset); in validate_tile_binning_config()
436 memcpy(exec->bo_index, untrusted, sizeof(exec->bo_index)); in validate_gem_handles()
494 uint32_t len = exec->args->bin_cl_size; in vc4_validate_bin_cl()
498 if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4)) in vc4_validate_bin_cl()
499 return -ENODEV; in vc4_validate_bin_cl()
510 return -EINVAL; in vc4_validate_bin_cl()
514 if (!info->name) { in vc4_validate_bin_cl()
517 return -EINVAL; in vc4_validate_bin_cl()
520 if (src_offset + info->len > len) { in vc4_validate_bin_cl()
523 src_offset, cmd, info->name, info->len, in vc4_validate_bin_cl()
525 return -EINVAL; in vc4_validate_bin_cl()
529 memcpy(dst_pkt, src_pkt, info->len); in vc4_validate_bin_cl()
531 if (info->func && info->func(exec, in vc4_validate_bin_cl()
535 src_offset, cmd, info->name); in vc4_validate_bin_cl()
536 return -EINVAL; in vc4_validate_bin_cl()
539 src_offset += info->len; in vc4_validate_bin_cl()
542 dst_offset += info->len; in vc4_validate_bin_cl()
549 exec->ct0ea = exec->ct0ca + dst_offset; in vc4_validate_bin_cl()
551 if (!exec->found_start_tile_binning_packet) { in vc4_validate_bin_cl()
553 return -EINVAL; in vc4_validate_bin_cl()
557 * semaphore is used to trigger the render CL to start up, and the in vc4_validate_bin_cl()
560 * render CL when they get called to) and actually triggers the queued in vc4_validate_bin_cl()
563 if (!exec->found_increment_semaphore_packet || !exec->found_flush) { in vc4_validate_bin_cl()
566 return -EINVAL; in vc4_validate_bin_cl()
579 uint32_t p0 = *(uint32_t *)(uniform_data_u + sample->p_offset[0]); in reloc_tex()
580 uint32_t p1 = *(uint32_t *)(uniform_data_u + sample->p_offset[1]); in reloc_tex()
581 uint32_t p2 = (sample->p_offset[2] != ~0 ? in reloc_tex()
582 *(uint32_t *)(uniform_data_u + sample->p_offset[2]) : 0); in reloc_tex()
583 uint32_t p3 = (sample->p_offset[3] != ~0 ? in reloc_tex()
584 *(uint32_t *)(uniform_data_u + sample->p_offset[3]) : 0); in reloc_tex()
585 uint32_t *validated_p0 = exec->uniforms_v + sample->p_offset[0]; in reloc_tex()
599 if (sample->is_direct) { in reloc_tex()
600 uint32_t remaining_size = tex->base.size - p0; in reloc_tex()
602 if (p0 > tex->base.size - 4) { in reloc_tex()
606 if (p1 > remaining_size - 4) { in reloc_tex()
611 *validated_p0 = tex->dma_addr + p0; in reloc_tex()
662 /* ETC1 is arranged as 64-bit blocks, where each block is 4x4 in reloc_tex()
699 uint32_t level_width = max(width >> i, 1u); in reloc_tex()
700 uint32_t level_height = max(height >> i, 1u); in reloc_tex()
728 DRM_DEBUG("Level %d (%dx%d -> %dx%d) size %db " in reloc_tex()
736 offset -= level_size; in reloc_tex()
739 *validated_p0 = tex->dma_addr + p0; in reloc_tex()
742 exec->bin_dep_seqno = max(exec->bin_dep_seqno, in reloc_tex()
743 to_vc4_bo(&tex->base)->write_seqno); in reloc_tex()
748 DRM_INFO("Texture p0 at %d: 0x%08x\n", sample->p_offset[0], p0); in reloc_tex()
749 DRM_INFO("Texture p1 at %d: 0x%08x\n", sample->p_offset[1], p1); in reloc_tex()
750 DRM_INFO("Texture p2 at %d: 0x%08x\n", sample->p_offset[2], p2); in reloc_tex()
751 DRM_INFO("Texture p3 at %d: 0x%08x\n", sample->p_offset[3], p3); in reloc_tex()
772 nr_attributes = state->addr & 0x7; in validate_gl_shader_rec()
775 packet_size = gl_shader_rec_size(state->addr); in validate_gl_shader_rec()
778 if (nr_relocs * 4 > exec->shader_rec_size) { in validate_gl_shader_rec()
781 nr_relocs, exec->shader_rec_size); in validate_gl_shader_rec()
782 return -EINVAL; in validate_gl_shader_rec()
784 src_handles = exec->shader_rec_u; in validate_gl_shader_rec()
785 exec->shader_rec_u += nr_relocs * 4; in validate_gl_shader_rec()
786 exec->shader_rec_size -= nr_relocs * 4; in validate_gl_shader_rec()
788 if (packet_size > exec->shader_rec_size) { in validate_gl_shader_rec()
791 packet_size, exec->shader_rec_size); in validate_gl_shader_rec()
792 return -EINVAL; in validate_gl_shader_rec()
794 pkt_u = exec->shader_rec_u; in validate_gl_shader_rec()
795 pkt_v = exec->shader_rec_v; in validate_gl_shader_rec()
797 exec->shader_rec_u += packet_size; in validate_gl_shader_rec()
803 BUG_ON(roundup(packet_size, 16) - packet_size > nr_relocs * 4); in validate_gl_shader_rec()
804 exec->shader_rec_v += roundup(packet_size, 16); in validate_gl_shader_rec()
805 exec->shader_rec_size -= packet_size; in validate_gl_shader_rec()
808 if (src_handles[i] > exec->bo_count) { in validate_gl_shader_rec()
810 return -EINVAL; in validate_gl_shader_rec()
813 bo[i] = to_drm_gem_dma_obj(exec->bo[src_handles[i]]); in validate_gl_shader_rec()
815 return -EINVAL; in validate_gl_shader_rec()
820 return -EINVAL; in validate_gl_shader_rec()
824 to_vc4_bo(&bo[0]->base)->validated_shader->is_threaded) { in validate_gl_shader_rec()
826 return -EINVAL; in validate_gl_shader_rec()
829 if (to_vc4_bo(&bo[1]->base)->validated_shader->is_threaded || in validate_gl_shader_rec()
830 to_vc4_bo(&bo[2]->base)->validated_shader->is_threaded) { in validate_gl_shader_rec()
832 return -EINVAL; in validate_gl_shader_rec()
843 *(uint32_t *)(pkt_v + o) = bo[i]->dma_addr + src_offset; in validate_gl_shader_rec()
848 return -EINVAL; in validate_gl_shader_rec()
851 validated_shader = to_vc4_bo(&bo[i]->base)->validated_shader; in validate_gl_shader_rec()
853 return -EINVAL; in validate_gl_shader_rec()
855 if (validated_shader->uniforms_src_size > in validate_gl_shader_rec()
856 exec->uniforms_size) { in validate_gl_shader_rec()
858 return -EINVAL; in validate_gl_shader_rec()
861 texture_handles_u = exec->uniforms_u; in validate_gl_shader_rec()
863 validated_shader->num_texture_samples); in validate_gl_shader_rec()
865 memcpy(exec->uniforms_v, uniform_data_u, in validate_gl_shader_rec()
866 validated_shader->uniforms_size); in validate_gl_shader_rec()
869 tex < validated_shader->num_texture_samples; in validate_gl_shader_rec()
873 &validated_shader->texture_samples[tex], in validate_gl_shader_rec()
876 return -EINVAL; in validate_gl_shader_rec()
881 * start-of-uniforms address (used for resetting the uniform in validate_gl_shader_rec()
885 uni < validated_shader->num_uniform_addr_offsets; in validate_gl_shader_rec()
887 uint32_t o = validated_shader->uniform_addr_offsets[uni]; in validate_gl_shader_rec()
888 ((uint32_t *)exec->uniforms_v)[o] = exec->uniforms_p; in validate_gl_shader_rec()
891 *(uint32_t *)(pkt_v + o + 4) = exec->uniforms_p; in validate_gl_shader_rec()
893 exec->uniforms_u += validated_shader->uniforms_src_size; in validate_gl_shader_rec()
894 exec->uniforms_v += validated_shader->uniforms_size; in validate_gl_shader_rec()
895 exec->uniforms_p += validated_shader->uniforms_size; in validate_gl_shader_rec()
907 exec->bin_dep_seqno = max(exec->bin_dep_seqno, in validate_gl_shader_rec()
908 to_vc4_bo(&vbo->base)->write_seqno); in validate_gl_shader_rec()
910 if (state->addr & 0x8) in validate_gl_shader_rec()
913 if (vbo->base.size < offset || in validate_gl_shader_rec()
914 vbo->base.size - offset < attr_size) { in validate_gl_shader_rec()
916 offset, attr_size, vbo->base.size); in validate_gl_shader_rec()
917 return -EINVAL; in validate_gl_shader_rec()
921 max_index = ((vbo->base.size - offset - attr_size) / in validate_gl_shader_rec()
923 if (state->max_index > max_index) { in validate_gl_shader_rec()
926 state->max_index, max_index); in validate_gl_shader_rec()
927 return -EINVAL; in validate_gl_shader_rec()
931 *(uint32_t *)(pkt_v + o) = vbo->dma_addr + offset; in validate_gl_shader_rec()
945 if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4)) in vc4_validate_shader_recs()
946 return -ENODEV; in vc4_validate_shader_recs()
948 for (i = 0; i < exec->shader_state_count; i++) { in vc4_validate_shader_recs()
949 ret = validate_gl_shader_rec(dev, exec, &exec->shader_state[i]); in vc4_validate_shader_recs()