Path: blob/21.2-virgl/src/gallium/drivers/nouveau/nv30/nv30_context.h
4574 views
#ifndef __NV30_CONTEXT_H__1#define __NV30_CONTEXT_H__23#include "pipe/p_format.h"4#include "util/u_blitter.h"56#include "nv30/nv30_screen.h"7#include "nv30/nv30_state.h"89#include "nouveau_context.h"1011#define BUFCTX_FB 012#define BUFCTX_VTXTMP 113#define BUFCTX_VTXBUF 214#define BUFCTX_IDXBUF 315#define BUFCTX_VERTTEX(n) (4 + (n))16#define BUFCTX_FRAGPROG 817#define BUFCTX_FRAGTEX(n) (9 + (n))1819#define NV30_NEW_BLEND (1 << 0)20#define NV30_NEW_RASTERIZER (1 << 1)21#define NV30_NEW_ZSA (1 << 2)22#define NV30_NEW_VERTPROG (1 << 3)23#define NV30_NEW_VERTCONST (1 << 4)24#define NV30_NEW_FRAGPROG (1 << 5)25#define NV30_NEW_FRAGCONST (1 << 6)26#define NV30_NEW_BLEND_COLOUR (1 << 7)27#define NV30_NEW_STENCIL_REF (1 << 8)28#define NV30_NEW_CLIP (1 << 9)29#define NV30_NEW_SAMPLE_MASK (1 << 10)30#define NV30_NEW_FRAMEBUFFER (1 << 11)31#define NV30_NEW_STIPPLE (1 << 12)32#define NV30_NEW_SCISSOR (1 << 13)33#define NV30_NEW_VIEWPORT (1 << 14)34#define NV30_NEW_ARRAYS (1 << 15)35#define NV30_NEW_VERTEX (1 << 16)36#define NV30_NEW_CONSTBUF (1 << 17)37#define NV30_NEW_FRAGTEX (1 << 18)38#define NV30_NEW_VERTTEX (1 << 19)39#define NV30_NEW_SWTNL (1 << 31)40#define NV30_NEW_ALL 0x000fffff4142struct nv30_context {43struct nouveau_context base;44struct nv30_screen *screen;45struct blitter_context *blitter;4647struct nouveau_bufctx *bufctx;4849struct {50unsigned rt_enable;51unsigned scissor_off;52unsigned num_vtxelts;53int index_bias;54bool prim_restart;55struct nv30_fragprog *fragprog;56} state;5758uint32_t dirty;5960struct draw_context *draw;61uint32_t draw_flags;62uint32_t draw_dirty;6364struct nv30_blend_stateobj *blend;65struct nv30_rasterizer_stateobj *rast;66struct nv30_zsa_stateobj *zsa;67struct nv30_vertex_stateobj *vertex;6869struct {70unsigned filter;71unsigned aniso;72} config;7374struct {75struct nv30_vertprog *program;7677struct pipe_resource *constbuf;78unsigned constbuf_nr;7980struct pipe_sampler_view *textures[PIPE_MAX_SAMPLERS];81unsigned num_textures;82struct nv30_sampler_state *samplers[PIPE_MAX_SAMPLERS];83unsigned num_samplers;84unsigned dirty_samplers;85} vertprog;8687struct {88struct nv30_fragprog *program;8990struct pipe_resource *constbuf;91unsigned constbuf_nr;9293struct pipe_sampler_view *textures[PIPE_MAX_SAMPLERS];94unsigned num_textures;95struct nv30_sampler_state *samplers[PIPE_MAX_SAMPLERS];96unsigned num_samplers;97unsigned dirty_samplers;98} fragprog;99100struct pipe_framebuffer_state framebuffer;101struct pipe_blend_color blend_colour;102struct pipe_stencil_ref stencil_ref;103struct pipe_poly_stipple stipple;104struct pipe_scissor_state scissor;105struct pipe_viewport_state viewport;106struct pipe_clip_state clip;107108unsigned sample_mask;109110struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];111unsigned num_vtxbufs;112uint32_t vbo_fifo;113uint32_t vbo_user;114unsigned vbo_min_index;115unsigned vbo_max_index;116bool vbo_push_hint;117118struct nouveau_heap *blit_vp;119struct pipe_resource *blit_fp;120121struct pipe_query *render_cond_query;122unsigned render_cond_mode;123bool render_cond_cond;124};125126static inline struct nv30_context *127nv30_context(struct pipe_context *pipe)128{129return (struct nv30_context *)pipe;130}131132struct pipe_context *133nv30_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags);134135void136nv30_vbo_init(struct pipe_context *pipe);137138void139nv30_vbo_validate(struct nv30_context *nv30);140141void142nv30_query_init(struct pipe_context *pipe);143144void145nv30_state_init(struct pipe_context *pipe);146147void148nv30_clear_init(struct pipe_context *pipe);149150void151nv30_vertprog_init(struct pipe_context *pipe);152153void154nv30_vertprog_validate(struct nv30_context *nv30);155156void157nv30_fragprog_init(struct pipe_context *pipe);158159void160nv30_fragprog_validate(struct nv30_context *nv30);161162void163nv30_texture_init(struct pipe_context *pipe);164165void166nv30_texture_validate(struct nv30_context *nv30);167168void169nv30_fragtex_init(struct pipe_context *pipe);170171void172nv30_fragtex_validate(struct nv30_context *nv30);173174void175nv40_verttex_init(struct pipe_context *pipe);176177void178nv40_verttex_validate(struct nv30_context *nv30);179180void181nv30_fragtex_sampler_states_bind(struct pipe_context *pipe,182unsigned nr, void **hwcso);183184void185nv40_verttex_sampler_states_bind(struct pipe_context *pipe,186unsigned nr, void **hwcso);187188void189nv40_verttex_set_sampler_views(struct pipe_context *pipe, unsigned nr,190struct pipe_sampler_view **views);191192void193nv30_fragtex_set_sampler_views(struct pipe_context *pipe,194unsigned nr, struct pipe_sampler_view **views);195196void197nv30_push_vbo(struct nv30_context *nv30, const struct pipe_draw_info *info,198const struct pipe_draw_start_count_bias *draw);199200void201nv30_draw_init(struct pipe_context *pipe);202203void204nv30_render_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info,205unsigned drawid_offset,206const struct pipe_draw_start_count_bias *draw);207208bool209nv30_state_validate(struct nv30_context *nv30, uint32_t mask, bool hwtnl);210211void212nv30_state_release(struct nv30_context *nv30);213214#ifdef NV30_3D_VERTEX_BEGIN_END215#define NV30_PRIM_GL_CASE(n) \216case PIPE_PRIM_##n: return NV30_3D_VERTEX_BEGIN_END_##n217218static inline unsigned219nv30_prim_gl(unsigned prim)220{221switch (prim) {222NV30_PRIM_GL_CASE(POINTS);223NV30_PRIM_GL_CASE(LINES);224NV30_PRIM_GL_CASE(LINE_LOOP);225NV30_PRIM_GL_CASE(LINE_STRIP);226NV30_PRIM_GL_CASE(TRIANGLES);227NV30_PRIM_GL_CASE(TRIANGLE_STRIP);228NV30_PRIM_GL_CASE(TRIANGLE_FAN);229NV30_PRIM_GL_CASE(QUADS);230NV30_PRIM_GL_CASE(QUAD_STRIP);231NV30_PRIM_GL_CASE(POLYGON);232default:233return NV30_3D_VERTEX_BEGIN_END_POINTS;234break;235}236}237#endif238239#endif240241242