X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fpipe%2Fp_state.h;h=af65d365bf0b6a79dc4fc6a324f6765aae4d12b9;hb=017f862de1f857bca29f09794539aaf411014f13;hp=d6ed514fb1c786d506c75f8ce79fa44be490bbd9;hpb=d747bf14dded3650da454d418912c921e65f2b9b;p=mesa.git diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index d6ed514fb1c..af65d365bf0 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -38,9 +38,8 @@ #ifndef PIPE_STATE_H #define PIPE_STATE_H -#include "mtypes.h" - - +#include "p_compiler.h" +#include "p_format.h" /** * Implementation limits @@ -50,11 +49,20 @@ #define PIPE_MAX_CONSTANT 32 #define PIPE_ATTRIB_MAX 32 #define PIPE_MAX_COLOR_BUFS 8 +#define PIPE_MAX_TEXTURE_LEVELS 16 +#define PIPE_MAX_FEEDBACK_ATTRIBS 16 +#define PIPE_MAX_SHADER_INPUTS 16 +#define PIPE_MAX_SHADER_OUTPUTS 16 /* fwd decl */ struct pipe_surface; +/* opaque type */ +struct pipe_buffer_handle; + +struct pipe_winsys; + /*** *** State objects @@ -62,147 +70,144 @@ struct pipe_surface; /** - * Primitive (point/line/tri) setup info + * Primitive (point/line/tri) rasterization info */ -struct pipe_setup_state +struct pipe_rasterizer_state { - GLuint flatshade:1; - GLuint light_twoside:1; - - GLuint front_winding:2; /**< PIPE_WINDING_x */ - - GLuint cull_mode:2; /**< PIPE_WINDING_x */ - - GLuint fill_cw:2; /**< PIPE_POLYGON_MODE_x */ - GLuint fill_ccw:2; /**< PIPE_POLYGON_MODE_x */ - - GLuint offset_cw:1; - GLuint offset_ccw:1; - - GLuint scissor:1; - - GLuint poly_smooth:1; - GLuint poly_stipple_enable:1; - - GLuint line_smooth:1; - GLuint line_stipple_enable:1; - - GLuint point_smooth:1; - - GLuint multisample:1; /* XXX maybe more ms state in future */ - - GLubyte line_stipple_factor; /**< [1..256] actually */ - GLushort line_stipple_pattern; - GLfloat line_width; - GLfloat point_size; /**< used when no per-vertex size */ - GLfloat offset_units; - GLfloat offset_scale; + unsigned flatshade:1; + unsigned light_twoside:1; + unsigned front_winding:2; /**< PIPE_WINDING_x */ + unsigned cull_mode:2; /**< PIPE_WINDING_x */ + unsigned fill_cw:2; /**< PIPE_POLYGON_MODE_x */ + unsigned fill_ccw:2; /**< PIPE_POLYGON_MODE_x */ + unsigned offset_cw:1; + unsigned offset_ccw:1; + unsigned scissor:1; + unsigned poly_smooth:1; + unsigned poly_stipple_enable:1; + unsigned point_smooth:1; + unsigned point_sprite:1; + unsigned point_size_per_vertex:1; /**< size computed in vertex shader */ + unsigned multisample:1; /* XXX maybe more ms state in future */ + unsigned line_smooth:1; + unsigned line_stipple_enable:1; + unsigned line_stipple_factor:8; /**< [1..256] actually */ + unsigned line_stipple_pattern:16; + unsigned bypass_clipping:1; + unsigned origin_lower_left:1; /**< Is (0,0) the lower-left corner? */ + + float line_width; + float point_size; /**< used when no per-vertex size */ + float offset_units; + float offset_scale; + ubyte sprite_coord_mode[PIPE_MAX_SHADER_OUTPUTS]; /**< PIPE_SPRITE_COORD_ */ }; + struct pipe_poly_stipple { - GLuint stipple[32]; + unsigned stipple[32]; }; struct pipe_viewport_state { - GLfloat scale[4]; - GLfloat translate[4]; + float scale[4]; + float translate[4]; }; struct pipe_scissor_state { - GLshort minx; - GLshort miny; - GLshort maxx; - GLshort maxy; + unsigned minx:16; + unsigned miny:16; + unsigned maxx:16; + unsigned maxy:16; }; struct pipe_clip_state { - GLfloat ucp[PIPE_MAX_CLIP_PLANES][4]; - GLuint nr; + float ucp[PIPE_MAX_CLIP_PLANES][4]; + unsigned nr; }; +/** + * Constants for vertex/fragment shaders + */ struct pipe_constant_buffer { - GLfloat constant[PIPE_MAX_CONSTANT][4]; - GLuint nr_constants; + struct pipe_buffer_handle *buffer; + unsigned size; /** in bytes */ }; -struct pipe_fs_state { - GLbitfield inputs_read; /* FRAG_ATTRIB_* */ +struct pipe_shader_state { const struct tgsi_token *tokens; - struct pipe_constant_buffer *constants; /* XXX temporary? */ + ubyte num_inputs; + ubyte num_outputs; + ubyte input_map[PIPE_MAX_SHADER_INPUTS]; /* XXX this may be temporary */ + ubyte input_semantic_name[PIPE_MAX_SHADER_INPUTS]; /**< TGSI_SEMANTIC_x */ + ubyte input_semantic_index[PIPE_MAX_SHADER_INPUTS]; + ubyte output_semantic_name[PIPE_MAX_SHADER_OUTPUTS]; /**< TGSI_SEMANTIC_x */ + ubyte output_semantic_index[PIPE_MAX_SHADER_OUTPUTS]; }; -struct pipe_depth_state +struct pipe_depth_stencil_state { - GLuint enabled:1; /**< depth test enabled? */ - GLuint writemask:1; /**< allow depth buffer writes? */ - GLuint func:3; /**< depth test func (PIPE_FUNC_x) */ - GLuint occlusion_count:1; /**< XXX move this elsewhere? */ - GLfloat clear; /**< Clear value in [0,1] (XXX correct place?) */ + struct { + unsigned enabled:1; /**< depth test enabled? */ + unsigned writemask:1; /**< allow depth buffer writes? */ + unsigned func:3; /**< depth test func (PIPE_FUNC_x) */ + unsigned occlusion_count:1; /**< XXX move this elsewhere? */ + } depth; + struct { + unsigned front_enabled:1; + unsigned front_func:3; /**< PIPE_FUNC_x */ + unsigned front_fail_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned front_zpass_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned front_zfail_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned back_enabled:1; + unsigned back_func:3; /**< PIPE_FUNC_x */ + unsigned back_fail_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned back_zpass_op:3; /**< PIPE_STENCIL_OP_x */ + unsigned back_zfail_op:3; /**< PIPE_STENCIL_OP_x */ + ubyte ref_value[2]; /**< [0] = front, [1] = back */ + ubyte value_mask[2]; + ubyte write_mask[2]; + } stencil; }; struct pipe_alpha_test_state { - GLuint enabled:1; - GLuint func:3; /**< PIPE_FUNC_x */ - GLfloat ref; /**< reference value */ + unsigned enabled:1; + unsigned func:3; /**< PIPE_FUNC_x */ + float ref; /**< reference value */ }; struct pipe_blend_state { - GLuint blend_enable:1; + unsigned blend_enable:1; - GLuint rgb_func:3; /**< PIPE_BLEND_x */ - GLuint rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */ - GLuint rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ + unsigned rgb_func:3; /**< PIPE_BLEND_x */ + unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */ + unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ - GLuint alpha_func:3; /**< PIPE_BLEND_x */ - GLuint alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */ - GLuint alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ + unsigned alpha_func:3; /**< PIPE_BLEND_x */ + unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */ + unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ - GLuint logicop_enable:1; - GLuint logicop_func:4; /**< PIPE_LOGICOP_x */ + unsigned logicop_enable:1; + unsigned logicop_func:4; /**< PIPE_LOGICOP_x */ - GLuint colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */ - GLuint dither:1; + unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */ + unsigned dither:1; }; struct pipe_blend_color { - GLfloat color[4]; + float color[4]; }; -struct pipe_clear_color_state -{ - GLfloat color[4]; -}; - -struct pipe_stencil_state { - GLuint front_enabled:1; - GLuint front_func:3; /**< PIPE_FUNC_x */ - GLuint front_fail_op:3; /**< PIPE_STENCIL_OP_x */ - GLuint front_zpass_op:3; /**< PIPE_STENCIL_OP_x */ - GLuint front_zfail_op:3; /**< PIPE_STENCIL_OP_x */ - GLuint back_enabled:1; - GLuint back_func:3; /**< PIPE_FUNC_x */ - GLuint back_fail_op:3; /**< PIPE_STENCIL_OP_x */ - GLuint back_zpass_op:3; /**< PIPE_STENCIL_OP_x */ - GLuint back_zfail_op:3; /**< PIPE_STENCIL_OP_x */ - GLubyte ref_value[2]; /**< [0] = front, [1] = back */ - GLubyte value_mask[2]; - GLubyte write_mask[2]; - GLubyte clear_value; -}; - - struct pipe_framebuffer_state { /** multiple colorbuffers for multiple render targets */ - GLuint num_cbufs; + unsigned num_cbufs; struct pipe_surface *cbufs[PIPE_MAX_COLOR_BUFS]; struct pipe_surface *zbuf; /**< Z buffer */ struct pipe_surface *sbuf; /**< Stencil buffer */ - struct pipe_surface *abuf; /**< Accum buffer */ }; @@ -211,89 +216,106 @@ struct pipe_framebuffer_state */ struct pipe_sampler_state { - GLuint wrap_s:3; /**< PIPE_TEX_WRAP_x */ - GLuint wrap_t:3; /**< PIPE_TEX_WRAP_x */ - GLuint wrap_r:3; /**< PIPE_TEX_WRAP_x */ - GLuint min_filter:3; /**< PIPE_TEX_FILTER_x */ - GLuint mag_filter:1; /**< PIPE_TEX_FILTER_LINEAR or _NEAREST */ - GLuint compare:1; /**< shadow/depth compare enabled? */ - GLenum compare_mode:1; /**< PIPE_TEX_COMPARE_x */ - GLenum compare_func:3; /**< PIPE_FUNC_x */ - GLfloat shadow_ambient; /**< shadow test fail color/intensity */ - GLfloat min_lod; - GLfloat max_lod; - GLfloat lod_bias; + unsigned wrap_s:3; /**< PIPE_TEX_WRAP_x */ + unsigned wrap_t:3; /**< PIPE_TEX_WRAP_x */ + unsigned wrap_r:3; /**< PIPE_TEX_WRAP_x */ + unsigned min_img_filter:2; /**< PIPE_TEX_FILTER_x */ + unsigned min_mip_filter:2; /**< PIPE_TEX_MIPFILTER_x */ + unsigned mag_img_filter:2; /**< PIPE_TEX_FILTER_x */ + unsigned compare:1; /**< shadow/depth compare enabled? */ + unsigned compare_mode:1; /**< PIPE_TEX_COMPARE_x */ + unsigned compare_func:3; /**< PIPE_FUNC_x */ + unsigned normalized_coords:1; /**< Are coords normalized to [0,1]? */ + float shadow_ambient; /**< shadow test fail color/intensity */ + float min_lod; + float max_lod; + float lod_bias; #if 0 /* need these? */ - GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */ - GLint MaxLevel; /**< max mipmap level, OpenGL 1.2 */ - GLfloat border_color[4]; + int BaseLevel; /**< min mipmap level, OpenGL 1.2 */ + int MaxLevel; /**< max mipmap level, OpenGL 1.2 */ #endif - GLfloat max_anisotropy; + float border_color[4]; + float max_anisotropy; }; -/*** - *** Resource Objects - ***/ - - -struct _DriBufferObject; - -struct pipe_region +/** + * 2D surface. This is basically a view into a memory buffer. + * May be a renderbuffer, texture mipmap level, etc. + */ +struct pipe_surface { - struct _DriBufferObject *buffer; /**< buffer manager's buffer ID */ + struct pipe_buffer_handle *buffer; /**< driver private buffer handle */ + ubyte *map; /**< only non-NULL when surface is actually mapped */ + unsigned map_refcount; /**< Reference count for mapping */ + enum pipe_format format; /**< PIPE_FORMAT_x */ + unsigned cpp; /**< bytes per pixel */ + unsigned width, height; + unsigned pitch; /**< in pixels */ + unsigned offset; /**< offset from start of buffer, in bytes */ + unsigned refcount; + struct pipe_winsys *winsys; /**< winsys which owns/created the surface */ +}; - GLuint refcount; /**< Reference count for region */ - GLuint cpp; /**< bytes per pixel */ - GLuint pitch; /**< in pixels */ - GLuint height; /**< in pixels */ - GLubyte *map; /**< only non-NULL when region is actually mapped */ - GLuint map_refcount; /**< Reference count for mapping */ - GLuint draw_offset; /**< Offset of drawing address within the region */ +/** + * Texture. Represents one or several texture images on one or several mipmap + * levels. + */ +struct pipe_texture +{ + /* Effectively the key: + */ + unsigned target; /**< PIPE_TEXTURE_x */ + enum pipe_format format; /**< PIPE_FORMAT_x */ + + unsigned first_level; + unsigned last_level; + + unsigned width[PIPE_MAX_TEXTURE_LEVELS]; + unsigned height[PIPE_MAX_TEXTURE_LEVELS]; + unsigned depth[PIPE_MAX_TEXTURE_LEVELS]; + unsigned cpp; + + unsigned compressed:1; + + /* These are also refcounted: + */ + unsigned refcount; }; /** - * 2D surface. - * May be a renderbuffer, texture mipmap level, etc. + * A vertex buffer. Typically, all the vertex data/attributes for + * drawing something will be in one buffer. But it's also possible, for + * example, to put colors in one buffer and texcoords in another. */ -struct pipe_surface +struct pipe_vertex_buffer { - struct pipe_region *region; - GLuint format:5; /**< PIPE_FORMAT_x */ - GLuint width, height; - - void *rb; /**< Ptr back to renderbuffer (temporary?) */ + unsigned pitch:11; /**< stride to same attrib in next vertex, in bytes */ + unsigned max_index; /**< number of vertices in this buffer */ + unsigned buffer_offset; /**< offset to start of data in buffer, in bytes */ + struct pipe_buffer_handle *buffer; /**< the actual buffer */ }; /** - * Texture object. - * Mipmap levels, cube faces, 3D slices can be accessed as surfaces. + * Information to describe a vertex attribute (position, color, etc) */ -struct pipe_texture_object +struct pipe_vertex_element { - GLuint type:2; /**< PIPE_TEXTURE_x */ - GLuint format:5; /**< PIPE_FORMAT_x */ - GLuint width:13; /**< 13 bits = 8K max size */ - GLuint height:13; - GLuint depth:13; - GLuint mipmapped:1; - - /** to access a 1D or 2D texture object as a surface */ - struct pipe_surface *(*get_2d_surface)(struct pipe_texture_object *pto, - GLuint level); - /** to access a 3D texture object as a surface */ - struct pipe_surface *(*get_3d_surface)(struct pipe_texture_object *pto, - GLuint level, GLuint slice); - /** to access a cube texture object as a surface */ - struct pipe_surface *(*get_cube_surface)(struct pipe_texture_object *pto, - GLuint face, GLuint level); - /** when finished with surface: */ - void (*release_surface)(struct pipe_texture_object *pto, - struct pipe_surface *ps); + /** Offset of this attribute, in bytes, from the start of the vertex */ + unsigned src_offset:11; + + /** Which vertex_buffer (as given to pipe->set_vertex_buffer()) does + * this attribute live in? + */ + unsigned vertex_buffer_index:5; + + unsigned dst_offset:8; + enum pipe_format src_format; /**< PIPE_FORMAT_* */ }; + #endif