#ifndef PIPE_STATE_H
#define PIPE_STATE_H
#include "p_compiler.h"
#include "p_defines.h"
#include "p_format.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PIPE_MAX_ATTRIBS 32
#define PIPE_MAX_CLIP_PLANES 8
#define PIPE_MAX_COLOR_BUFS 8
#define PIPE_MAX_CONSTANT_BUFFERS 32
#define PIPE_MAX_SAMPLERS 32
#define PIPE_MAX_SHADER_INPUTS 80
#define PIPE_MAX_SHADER_OUTPUTS 80
#define PIPE_MAX_SHADER_SAMPLER_VIEWS 128
#define PIPE_MAX_SHADER_BUFFERS 32
#define PIPE_MAX_SHADER_IMAGES 32
#define PIPE_MAX_TEXTURE_LEVELS 16
#define PIPE_MAX_SO_BUFFERS 4
#define PIPE_MAX_SO_OUTPUTS 64
#define PIPE_MAX_VIEWPORTS 16
#define PIPE_MAX_CLIP_OR_CULL_DISTANCE_COUNT 8
#define PIPE_MAX_CLIP_OR_CULL_DISTANCE_ELEMENT_COUNT 2
#define PIPE_MAX_WINDOW_RECTANGLES 8
#define PIPE_MAX_SAMPLE_LOCATION_GRID_SIZE 4
#define PIPE_MAX_HW_ATOMIC_BUFFERS 32
#define PIPE_MAX_VERTEX_STREAMS 4
struct pipe_reference
{
int32_t count;
};
struct pipe_rasterizer_state
{
unsigned flatshade:1;
unsigned light_twoside:1;
unsigned clamp_vertex_color:1;
unsigned clamp_fragment_color:1;
unsigned front_ccw:1;
unsigned cull_face:2;
unsigned fill_front:2;
unsigned fill_back:2;
unsigned offset_point:1;
unsigned offset_line:1;
unsigned offset_tri:1;
unsigned scissor:1;
unsigned poly_smooth:1;
unsigned poly_stipple_enable:1;
unsigned point_smooth:1;
unsigned sprite_coord_mode:1;
unsigned point_quad_rasterization:1;
unsigned point_tri_clip:1;
unsigned point_size_per_vertex:1;
unsigned multisample:1;
unsigned force_persample_interp:1;
unsigned line_smooth:1;
unsigned line_stipple_enable:1;
unsigned line_last_pixel:1;
unsigned conservative_raster_mode:2;
unsigned flatshade_first:1;
unsigned half_pixel_center:1;
unsigned bottom_edge_rule:1;
unsigned subpixel_precision_x:4;
unsigned subpixel_precision_y:4;
unsigned rasterizer_discard:1;
unsigned tile_raster_order_fixed:1;
unsigned tile_raster_order_increasing_x:1;
unsigned tile_raster_order_increasing_y:1;
unsigned depth_clip_near:1;
unsigned depth_clip_far:1;
unsigned clip_halfz:1;
unsigned offset_units_unscaled:1;
unsigned clip_plane_enable:PIPE_MAX_CLIP_PLANES;
unsigned line_stipple_factor:8;
unsigned line_stipple_pattern:16;
uint16_t sprite_coord_enable;
float line_width;
float point_size;
float offset_units;
float offset_scale;
float offset_clamp;
float conservative_raster_dilate;
};
struct pipe_poly_stipple
{
unsigned stipple[32];
};
struct pipe_viewport_state
{
float scale[3];
float translate[3];
enum pipe_viewport_swizzle swizzle_x:3;
enum pipe_viewport_swizzle swizzle_y:3;
enum pipe_viewport_swizzle swizzle_z:3;
enum pipe_viewport_swizzle swizzle_w:3;
};
struct pipe_scissor_state
{
unsigned minx:16;
unsigned miny:16;
unsigned maxx:16;
unsigned maxy:16;
};
struct pipe_clip_state
{
float ucp[PIPE_MAX_CLIP_PLANES][4];
};
struct pipe_stream_output
{
unsigned register_index:6;
unsigned start_component:2;
unsigned num_components:3;
unsigned output_buffer:3;
unsigned dst_offset:16;
unsigned stream:2;
};
struct pipe_stream_output_info
{
unsigned num_outputs;
uint16_t stride[PIPE_MAX_SO_BUFFERS];
struct pipe_stream_output output[PIPE_MAX_SO_OUTPUTS];
};
struct pipe_shader_state
{
enum pipe_shader_ir type;
const struct tgsi_token *tokens;
union {
void *native;
void *nir;
} ir;
struct pipe_stream_output_info stream_output;
};
static inline void
pipe_shader_state_from_tgsi(struct pipe_shader_state *state,
const struct tgsi_token *tokens)
{
state->type = PIPE_SHADER_IR_TGSI;
state->tokens = tokens;
memset(&state->stream_output, 0, sizeof(state->stream_output));
}
struct pipe_depth_state
{
unsigned enabled:1;
unsigned writemask:1;
unsigned func:3;
unsigned bounds_test:1;
float bounds_min;
float bounds_max;
};
struct pipe_stencil_state
{
unsigned enabled:1;
unsigned func:3;
unsigned fail_op:3;
unsigned zpass_op:3;
unsigned zfail_op:3;
unsigned valuemask:8;
unsigned writemask:8;
};
struct pipe_alpha_state
{
unsigned enabled:1;
unsigned func:3;
float ref_value;
};
struct pipe_depth_stencil_alpha_state
{
struct pipe_depth_state depth;
struct pipe_stencil_state stencil[2];
struct pipe_alpha_state alpha;
};
struct pipe_rt_blend_state
{
unsigned blend_enable:1;
unsigned rgb_func:3;
unsigned rgb_src_factor:5;
unsigned rgb_dst_factor:5;
unsigned alpha_func:3;
unsigned alpha_src_factor:5;
unsigned alpha_dst_factor:5;
unsigned colormask:4;
};
struct pipe_blend_state
{
unsigned independent_blend_enable:1;
unsigned logicop_enable:1;
unsigned logicop_func:4;
unsigned dither:1;
unsigned alpha_to_coverage:1;
unsigned alpha_to_coverage_dither:1;
unsigned alpha_to_one:1;
unsigned max_rt:3;
struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS];
};
struct pipe_blend_color
{
float color[4];
};
struct pipe_stencil_ref
{
ubyte ref_value[2];
};
struct pipe_framebuffer_state
{
uint16_t width, height;
uint16_t layers;
ubyte samples;
ubyte nr_cbufs;
struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS];
struct pipe_surface *zsbuf;
};
struct pipe_sampler_state
{
unsigned wrap_s:3;
unsigned wrap_t:3;
unsigned wrap_r:3;
unsigned min_img_filter:1;
unsigned min_mip_filter:2;
unsigned mag_img_filter:1;
unsigned compare_mode:1;
unsigned compare_func:3;
unsigned normalized_coords:1;
unsigned max_anisotropy:5;
unsigned seamless_cube_map:1;
float lod_bias;
float min_lod, max_lod;
union pipe_color_union border_color;
};
union pipe_surface_desc {
struct {
unsigned level;
unsigned first_layer:16;
unsigned last_layer:16;
} tex;
struct {
unsigned first_element;
unsigned last_element;
} buf;
};
struct pipe_surface
{
struct pipe_reference reference;
enum pipe_format format:16;
unsigned writable:1;
struct pipe_resource *texture;
struct pipe_context *context;
uint16_t width;
uint16_t height;
unsigned nr_samples:8;
union pipe_surface_desc u;
};
struct pipe_sampler_view
{
struct pipe_reference reference;
enum pipe_format format:15;
enum pipe_texture_target target:5;
unsigned swizzle_r:3;
unsigned swizzle_g:3;
unsigned swizzle_b:3;
unsigned swizzle_a:3;
struct pipe_resource *texture;
struct pipe_context *context;
union {
struct {
unsigned first_layer:16;
unsigned last_layer:16;
unsigned first_level:8;
unsigned last_level:8;
} tex;
struct {
unsigned offset;
unsigned size;
} buf;
} u;
};
struct pipe_image_view
{
struct pipe_resource *resource;
enum pipe_format format;
uint16_t access;
uint16_t shader_access;
union {
struct {
unsigned first_layer:16;
unsigned last_layer:16;
unsigned level:8;
} tex;
struct {
unsigned offset;
unsigned size;
} buf;
} u;
};
struct pipe_box
{
int x;
int16_t y;
int16_t z;
int width;
int16_t height;
int16_t depth;
};
struct pipe_resource
{
struct pipe_reference reference;
unsigned width0;
uint16_t height0;
uint16_t depth0;
uint16_t array_size;
enum pipe_format format:16;
enum pipe_texture_target target:8;
unsigned last_level:8;
unsigned nr_samples:8;
unsigned nr_storage_samples:8;
unsigned usage:8;
unsigned bind;
unsigned flags;
struct pipe_resource *next;
struct pipe_screen *screen;
};
struct pipe_transfer
{
struct pipe_resource *resource;
unsigned level;
enum pipe_transfer_usage usage;
struct pipe_box box;
unsigned stride;
unsigned layer_stride;
};
struct pipe_vertex_buffer
{
uint16_t stride;
bool is_user_buffer;
unsigned buffer_offset;
union {
struct pipe_resource *resource;
const void *user;
} buffer;
};
struct pipe_constant_buffer
{
struct pipe_resource *buffer;
unsigned buffer_offset;
unsigned buffer_size;
const void *user_buffer;
};
struct pipe_shader_buffer {
struct pipe_resource *buffer;
unsigned buffer_offset;
unsigned buffer_size;
};
struct pipe_stream_output_target
{
struct pipe_reference reference;
struct pipe_resource *buffer;
struct pipe_context *context;
unsigned buffer_offset;
unsigned buffer_size;
};
struct pipe_vertex_element
{
unsigned src_offset:16;
unsigned vertex_buffer_index:5;
enum pipe_format src_format:11;
unsigned instance_divisor;
};
struct pipe_draw_indirect_info
{
unsigned offset;
unsigned stride;
unsigned draw_count;
unsigned indirect_draw_count_offset;
struct pipe_resource *buffer;
struct pipe_resource *indirect_draw_count;
};
struct pipe_draw_info
{
ubyte index_size;
enum pipe_prim_type mode:8;
unsigned primitive_restart:1;
unsigned has_user_indices:1;
ubyte vertices_per_patch;
unsigned start;
unsigned count;
unsigned start_instance;
unsigned instance_count;
unsigned drawid;
int index_bias;
unsigned min_index;
unsigned max_index;
unsigned restart_index;
union {
struct pipe_resource *resource;
const void *user;
} index;
struct pipe_draw_indirect_info *indirect;
struct pipe_stream_output_target *count_from_stream_output;
};
struct pipe_blit_info
{
struct {
struct pipe_resource *resource;
unsigned level;
struct pipe_box box;
enum pipe_format format;
} dst, src;
unsigned mask;
unsigned filter;
bool scissor_enable;
struct pipe_scissor_state scissor;
bool window_rectangle_include;
unsigned num_window_rectangles;
struct pipe_scissor_state window_rectangles[PIPE_MAX_WINDOW_RECTANGLES];
bool render_condition_enable;
bool alpha_blend;
};
struct pipe_grid_info
{
uint32_t pc;
void *input;
uint work_dim;
uint block[3];
uint last_block[3];
uint grid[3];
struct pipe_resource *indirect;
unsigned indirect_offset;
};
struct pipe_binary_program_header
{
uint32_t num_bytes;
char blob[];
};
struct pipe_compute_state
{
enum pipe_shader_ir ir_type;
const void *prog;
unsigned req_local_mem;
unsigned req_private_mem;
unsigned req_input_mem;
};
struct pipe_debug_callback
{
bool async;
void (*debug_message)(void *data,
unsigned *id,
enum pipe_debug_type type,
const char *fmt,
va_list args);
void *data;
};
struct pipe_device_reset_callback
{
void (*reset)(void *data, enum pipe_reset_status status);
void *data;
};
struct pipe_memory_info
{
unsigned total_device_memory;
unsigned avail_device_memory;
unsigned total_staging_memory;
unsigned avail_staging_memory;
unsigned device_memory_evicted;
unsigned nr_device_memory_evictions;
};
struct pipe_memory_object
{
bool dedicated;
};
#ifdef __cplusplus
}
#endif
#endif