Path: blob/21.2-virgl/src/intel/compiler/brw_compile_clip.c
4550 views
/*1* Copyright © 2006 - 2017 Intel Corporation2*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, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#include "brw_clip.h"2425#include "dev/intel_debug.h"2627const unsigned *28brw_compile_clip(const struct brw_compiler *compiler,29void *mem_ctx,30const struct brw_clip_prog_key *key,31struct brw_clip_prog_data *prog_data,32struct brw_vue_map *vue_map,33unsigned *final_assembly_size)34{35struct brw_clip_compile c;36memset(&c, 0, sizeof(c));3738/* Begin the compilation:39*/40brw_init_codegen(compiler->devinfo, &c.func, mem_ctx);4142c.func.single_program_flow = 1;4344c.key = *key;45c.vue_map = *vue_map;4647/* nr_regs is the number of registers filled by reading data from the VUE.48* This program accesses the entire VUE, so nr_regs needs to be the size of49* the VUE (measured in pairs, since two slots are stored in each50* register).51*/52c.nr_regs = (c.vue_map.num_slots + 1)/2;5354c.prog_data.clip_mode = c.key.clip_mode; /* XXX */5556/* For some reason the thread is spawned with only 4 channels57* unmasked.58*/59brw_set_default_mask_control(&c.func, BRW_MASK_DISABLE);6061/* Would ideally have the option of producing a program which could62* do all three:63*/64switch (key->primitive) {65case GL_TRIANGLES:66if (key->do_unfilled)67brw_emit_unfilled_clip( &c );68else69brw_emit_tri_clip( &c );70break;71case GL_LINES:72brw_emit_line_clip( &c );73break;74case GL_POINTS:75brw_emit_point_clip( &c );76break;77default:78unreachable("not reached");79}8081brw_compact_instructions(&c.func, 0, NULL);8283*prog_data = c.prog_data;8485const unsigned *program = brw_get_program(&c.func, final_assembly_size);8687if (INTEL_DEBUG & DEBUG_CLIP) {88fprintf(stderr, "clip:\n");89brw_disassemble_with_labels(compiler->devinfo,90program, 0, *final_assembly_size, stderr);91fprintf(stderr, "\n");92}9394return program;95}969798