Path: blob/21.2-virgl/src/gallium/auxiliary/draw/draw_gs.h
4565 views
/**************************************************************************1*2* Copyright 2009 VMware, Inc.3* All Rights Reserved.4*5* Permission is hereby granted, free of charge, to any person obtaining a6* copy of this software and associated documentation files (the7* "Software"), to deal in the Software without restriction, including8* without limitation the rights to use, copy, modify, merge, publish,9* distribute, sub license, and/or sell copies of the Software, and to10* permit persons to whom the Software is furnished to do so, subject to11* the following conditions:12*13* The above copyright notice and this permission notice (including the14* next paragraph) shall be included in all copies or substantial portions15* of the Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS18* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF19* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.20* IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR21* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,22* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE23* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.24*25**************************************************************************/2627#ifndef DRAW_GS_H28#define DRAW_GS_H2930#include "draw_context.h"31#include "tgsi/tgsi_exec.h"32#include "draw_private.h"3334#define MAX_TGSI_PRIMITIVES 43536struct draw_context;3738#ifdef DRAW_LLVM_AVAILABLE39struct draw_gs_jit_context;40struct draw_gs_llvm_variant;4142/**43* Structure holding the inputs to the geometry shader. It uses SOA layout.44* The dimensions are as follows:45* - maximum number of vertices for a geometry shader input primitive46* (6 for triangle_adjacency)47* - maximum number of attributes for each vertex48* - four channels per each attribute (x,y,z,w)49* - number of input primitives equal to the SOA vector length50*/51struct draw_gs_inputs {52float data[6][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS][TGSI_NUM_CHANNELS];53};54#endif5556/**57* Private version of the compiled geometry shader58*/59struct draw_vertex_stream {60unsigned *primitive_lengths;61unsigned emitted_vertices;62unsigned emitted_primitives;63float (*tmp_output)[4];64};6566struct draw_geometry_shader {67struct draw_context *draw;6869struct tgsi_exec_machine *machine;7071/* This member will disappear shortly:*/72struct pipe_shader_state state;7374struct tgsi_shader_info info;75unsigned position_output;76unsigned viewport_index_output;77unsigned ccdistance_output[PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT];7879unsigned max_output_vertices;80unsigned primitive_boundary;81unsigned input_primitive;82unsigned output_primitive;83unsigned vertex_size;8485struct draw_vertex_stream stream[TGSI_MAX_VERTEX_STREAMS];86unsigned num_vertex_streams;8788unsigned in_prim_idx;89unsigned input_vertex_stride;90unsigned fetched_prim_count;91const float (*input)[4];92const struct tgsi_shader_info *input_info;93unsigned vector_length;94unsigned max_out_prims;9596unsigned num_invocations;97unsigned invocation_id;98#ifdef DRAW_LLVM_AVAILABLE99struct draw_gs_inputs *gs_input;100struct draw_gs_jit_context *jit_context;101struct draw_gs_llvm_variant *current_variant;102struct vertex_header *gs_output[PIPE_MAX_VERTEX_STREAMS];103104int **llvm_prim_lengths;105int *llvm_emitted_primitives;106int *llvm_emitted_vertices;107int *llvm_prim_ids;108#endif109110void (*fetch_inputs)(struct draw_geometry_shader *shader,111unsigned *indices,112unsigned num_vertices,113unsigned prim_idx);114void (*fetch_outputs)(struct draw_geometry_shader *shader,115unsigned vertex_stream,116unsigned num_primitives,117float (**p_output)[4]);118119void (*prepare)(struct draw_geometry_shader *shader,120const void *constants[PIPE_MAX_CONSTANT_BUFFERS],121const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS]);122void (*run)(struct draw_geometry_shader *shader,123unsigned input_primitives, unsigned *out_prims);124};125126void draw_geometry_shader_new_instance(struct draw_geometry_shader *gs);127128/*129* Returns the number of vertices emitted.130* The vertex shader can emit any number of vertices as long as it's131* smaller than the GS_MAX_OUTPUT_VERTICES shader property.132*/133int draw_geometry_shader_run(struct draw_geometry_shader *shader,134const void *constants[PIPE_MAX_CONSTANT_BUFFERS],135const unsigned constants_size[PIPE_MAX_CONSTANT_BUFFERS],136const struct draw_vertex_info *input_verts,137const struct draw_prim_info *input_prim,138const struct tgsi_shader_info *input_info,139struct draw_vertex_info *output_verts,140struct draw_prim_info *output_prims );141142void draw_geometry_shader_prepare(struct draw_geometry_shader *shader,143struct draw_context *draw);144145int draw_gs_max_output_vertices(struct draw_geometry_shader *shader,146unsigned pipe_prim);147148#ifdef DRAW_LLVM_AVAILABLE149void draw_gs_set_current_variant(struct draw_geometry_shader *shader,150struct draw_gs_llvm_variant *variant);151#endif152153#endif154155156