X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fsvga%2Fsvga_context.h;h=6c86ba53cdbeca660c24db51b9ddce23ed4688bb;hb=a4ace98a9733b3e83d971f4871c2908749c0e5c8;hp=bcce18a3502536a3da6638b7caac551285b22959;hpb=958fc04dc51a2561c8598f42df59e3d9139e56a7;p=mesa.git diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index bcce18a3502..6c86ba53cdb 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -31,6 +31,8 @@ #include "pipe/p_defines.h" #include "pipe/p_state.h" +#include "os/os_time.h" + #include "util/u_blitter.h" #include "util/list.h" @@ -44,21 +46,36 @@ /** Non-GPU queries for gallium HUD */ +enum svga_hud { /* per-frame counters */ -#define SVGA_QUERY_NUM_DRAW_CALLS (PIPE_QUERY_DRIVER_SPECIFIC + 0) -#define SVGA_QUERY_NUM_FALLBACKS (PIPE_QUERY_DRIVER_SPECIFIC + 1) -#define SVGA_QUERY_NUM_FLUSHES (PIPE_QUERY_DRIVER_SPECIFIC + 2) -#define SVGA_QUERY_NUM_VALIDATIONS (PIPE_QUERY_DRIVER_SPECIFIC + 3) -#define SVGA_QUERY_MAP_BUFFER_TIME (PIPE_QUERY_DRIVER_SPECIFIC + 4) -#define SVGA_QUERY_NUM_RESOURCES_MAPPED (PIPE_QUERY_DRIVER_SPECIFIC + 5) + SVGA_QUERY_NUM_DRAW_CALLS = PIPE_QUERY_DRIVER_SPECIFIC, + SVGA_QUERY_NUM_FALLBACKS, + SVGA_QUERY_NUM_FLUSHES, + SVGA_QUERY_NUM_VALIDATIONS, + SVGA_QUERY_MAP_BUFFER_TIME, + SVGA_QUERY_NUM_BUFFERS_MAPPED, + SVGA_QUERY_NUM_TEXTURES_MAPPED, + SVGA_QUERY_NUM_BYTES_UPLOADED, + SVGA_QUERY_COMMAND_BUFFER_SIZE, + SVGA_QUERY_FLUSH_TIME, + SVGA_QUERY_SURFACE_WRITE_FLUSHES, + SVGA_QUERY_NUM_READBACKS, + SVGA_QUERY_NUM_RESOURCE_UPDATES, + SVGA_QUERY_NUM_BUFFER_UPLOADS, + SVGA_QUERY_NUM_CONST_BUF_UPDATES, + SVGA_QUERY_NUM_CONST_UPDATES, + /* running total counters */ -#define SVGA_QUERY_MEMORY_USED (PIPE_QUERY_DRIVER_SPECIFIC + 6) -#define SVGA_QUERY_NUM_SHADERS (PIPE_QUERY_DRIVER_SPECIFIC + 7) -#define SVGA_QUERY_NUM_RESOURCES (PIPE_QUERY_DRIVER_SPECIFIC + 8) -#define SVGA_QUERY_NUM_STATE_OBJECTS (PIPE_QUERY_DRIVER_SPECIFIC + 9) -#define SVGA_QUERY_NUM_SURFACE_VIEWS (PIPE_QUERY_DRIVER_SPECIFIC + 10) + SVGA_QUERY_MEMORY_USED, + SVGA_QUERY_NUM_SHADERS, + SVGA_QUERY_NUM_RESOURCES, + SVGA_QUERY_NUM_STATE_OBJECTS, + SVGA_QUERY_NUM_SURFACE_VIEWS, + SVGA_QUERY_NUM_GENERATE_MIPMAP, + /*SVGA_QUERY_MAX has to be last because it is size of an array*/ -#define SVGA_QUERY_MAX (PIPE_QUERY_DRIVER_SPECIFIC + 11) + SVGA_QUERY_MAX +}; /** * Maximum supported number of constant buffers per shader @@ -72,6 +89,8 @@ */ #define SVGA_MAX_CONST_BUF_SIZE (4096 * 4 * sizeof(int)) +#define CONST0_UPLOAD_ALIGNMENT 256 + struct draw_vertex_shader; struct draw_fragment_shader; struct svga_shader_variant; @@ -278,6 +297,8 @@ struct svga_state struct { unsigned flag_1d; unsigned flag_srgb; + unsigned flag_rect; /* sampler views with rectangular texture target */ + unsigned flag_buf; /* sampler views with texture buffer target */ } tex_flags; unsigned sample_mask; @@ -310,28 +331,42 @@ struct svga_hw_view_state struct svga_sampler_view *v; unsigned min_lod; unsigned max_lod; - int dirty; + boolean dirty; }; /* Updated by calling svga_update_state( SVGA_STATE_HW_DRAW ) */ struct svga_hw_draw_state { + /** VGPU9 rasterization state */ unsigned rs[SVGA3D_RS_MAX]; + /** VGPU9 texture sampler and bindings state */ unsigned ts[SVGA3D_PIXEL_SAMPLERREG_MAX][SVGA3D_TS_MAX]; + /** VGPU9 texture views */ + unsigned num_views; + struct svga_hw_view_state views[PIPE_MAX_SAMPLERS]; + /** VGPU9 constant buffer values */ float cb[PIPE_SHADER_TYPES][SVGA3D_CONSTREG_MAX][4]; + /** Currently bound shaders */ struct svga_shader_variant *fs; struct svga_shader_variant *vs; struct svga_shader_variant *gs; - struct svga_hw_view_state views[PIPE_MAX_SAMPLERS]; - unsigned num_views; + + /** Currently bound constant buffer, per shader stage */ struct pipe_resource *constbuf[PIPE_SHADER_TYPES]; - /* Bitmask of enabled constant bufffers */ + /** Bitmask of enabled constant buffers */ unsigned enabled_constbufs[PIPE_SHADER_TYPES]; - /* VGPU10 HW state (used to prevent emitting redundant state) */ + /** + * These are used to reduce the number of times we call u_upload_unmap() + * while updating the zero-th/default VGPU10 constant buffer. + */ + struct pipe_resource *const0_buffer; + struct svga_winsys_surface *const0_handle; + + /** VGPU10 HW state (used to prevent emitting redundant state) */ SVGA3dDepthStencilStateId depth_stencil_id; unsigned stencil_ref; SVGA3dBlendStateId blend_id; @@ -341,8 +376,27 @@ struct svga_hw_draw_state SVGA3dElementLayoutId layout_id; SVGA3dPrimitiveType topology; - /* used for rebinding */ + /** Vertex buffer state */ + SVGA3dVertexBuffer vbuffer_attrs[PIPE_MAX_ATTRIBS]; + struct pipe_resource *vbuffers[PIPE_MAX_ATTRIBS]; + unsigned num_vbuffers; + + struct pipe_resource *ib; /**< index buffer for drawing */ + SVGA3dSurfaceFormat ib_format; + unsigned ib_offset; + + unsigned num_samplers[PIPE_SHADER_TYPES]; + SVGA3dSamplerId samplers[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; + unsigned num_sampler_views[PIPE_SHADER_TYPES]; + struct pipe_sampler_view + *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; + + unsigned num_rendertargets; + struct pipe_surface *rtv[SVGA3D_MAX_RENDER_TARGETS]; + struct pipe_surface *dsv; + + /* used for rebinding */ unsigned default_constbuf_size[PIPE_SHADER_TYPES]; }; @@ -377,6 +431,7 @@ struct svga_context struct svga_winsys_context *swc; struct blitter_context *blitter; struct u_upload_mgr *const0_upload; + struct u_upload_mgr *tex_upload; struct { boolean no_swtnl; @@ -386,10 +441,11 @@ struct svga_context /* incremented for each shader */ unsigned shader_id; - unsigned disable_shader; - boolean no_line_width; boolean force_hw_line_stipple; + + /** To report perf/conformance/etc issues to the state tracker */ + struct pipe_debug_callback callback; } debug; struct { @@ -476,15 +532,36 @@ struct svga_context /** performance / info queries for HUD */ struct { - uint64_t num_draw_calls; /**< SVGA_QUERY_DRAW_CALLS */ - uint64_t num_fallbacks; /**< SVGA_QUERY_NUM_FALLBACKS */ - uint64_t num_flushes; /**< SVGA_QUERY_NUM_FLUSHES */ - uint64_t num_validations; /**< SVGA_QUERY_NUM_VALIDATIONS */ - uint64_t map_buffer_time; /**< SVGA_QUERY_MAP_BUFFER_TIME */ - uint64_t num_resources_mapped; /**< SVGA_QUERY_NUM_RESOURCES_MAPPED */ - uint64_t num_shaders; /**< SVGA_QUERY_NUM_SHADERS */ - uint64_t num_state_objects; /**< SVGA_QUERY_NUM_STATE_OBJECTS */ - uint64_t num_surface_views; /**< SVGA_QUERY_NUM_SURFACE_VIEWS */ + uint64_t num_draw_calls; /**< SVGA_QUERY_DRAW_CALLS */ + uint64_t num_fallbacks; /**< SVGA_QUERY_NUM_FALLBACKS */ + uint64_t num_flushes; /**< SVGA_QUERY_NUM_FLUSHES */ + uint64_t num_validations; /**< SVGA_QUERY_NUM_VALIDATIONS */ + uint64_t map_buffer_time; /**< SVGA_QUERY_MAP_BUFFER_TIME */ + uint64_t num_buffers_mapped; /**< SVGA_QUERY_NUM_BUFFERS_MAPPED */ + uint64_t num_textures_mapped; /**< SVGA_QUERY_NUM_TEXTURES_MAPPED */ + uint64_t command_buffer_size; /**< SVGA_QUERY_COMMAND_BUFFER_SIZE */ + uint64_t flush_time; /**< SVGA_QUERY_FLUSH_TIME */ + uint64_t surface_write_flushes; /**< SVGA_QUERY_SURFACE_WRITE_FLUSHES */ + uint64_t num_readbacks; /**< SVGA_QUERY_NUM_READBACKS */ + uint64_t num_resource_updates; /**< SVGA_QUERY_NUM_RESOURCE_UPDATES */ + uint64_t num_buffer_uploads; /**< SVGA_QUERY_NUM_BUFFER_UPLOADS */ + uint64_t num_const_buf_updates; /**< SVGA_QUERY_NUM_CONST_BUF_UPDATES */ + uint64_t num_const_updates; /**< SVGA_QUERY_NUM_CONST_UPDATES */ + uint64_t num_shaders; /**< SVGA_QUERY_NUM_SHADERS */ + + /** The following are summed for SVGA_QUERY_NUM_STATE_OBJECTS */ + uint64_t num_blend_objects; + uint64_t num_depthstencil_objects; + uint64_t num_rasterizer_objects; + uint64_t num_sampler_objects; + uint64_t num_samplerview_objects; + uint64_t num_vertexelement_objects; + + uint64_t num_surface_views; /**< SVGA_QUERY_NUM_SURFACE_VIEWS */ + uint64_t num_bytes_uploaded; /**< SVGA_QUERY_NUM_BYTES_UPLOADED */ + uint64_t num_generate_mipmap; /**< SVGA_QUERY_NUM_GENERATE_MIPMAP */ + + boolean uses_time; /**< os_time_get() calls needed? */ } hud; /** The currently bound stream output targets */ @@ -506,6 +583,14 @@ struct svga_context /** Alternate rasterizer states created for point sprite */ struct svga_rasterizer_state *rasterizer_no_cull[2]; + + /** Current conditional rendering predicate */ + struct { + SVGA3dQueryId query_id; + boolean cond; + } pred; + + boolean render_condition; }; /* A flag for each state_tracker state object: @@ -540,26 +625,7 @@ struct svga_context #define SVGA_NEW_GS 0x10000000 #define SVGA_NEW_GS_CONST_BUFFER 0x20000000 #define SVGA_NEW_GS_VARIANT 0x40000000 - - - - -/*********************************************************************** - * svga_clear.c: - */ -void svga_clear(struct pipe_context *pipe, - unsigned buffers, - const union pipe_color_union *color, - double depth, - unsigned stencil); - - -/*********************************************************************** - * svga_screen_texture.c: - */ -void svga_mark_surfaces_dirty(struct svga_context *svga); - - +#define SVGA_NEW_TEXTURE_CONSTS 0x80000000 void svga_init_state_functions( struct svga_context *svga ); @@ -581,8 +647,10 @@ void svga_init_draw_functions( struct svga_context *svga ); void svga_init_query_functions( struct svga_context *svga ); void svga_init_surface_functions(struct svga_context *svga); void svga_init_stream_output_functions( struct svga_context *svga ); +void svga_init_clear_functions( struct svga_context *svga ); void svga_cleanup_vertex_state( struct svga_context *svga ); +void svga_cleanup_sampler_state( struct svga_context *svga ); void svga_cleanup_tss_binding( struct svga_context *svga ); void svga_cleanup_framebuffer( struct svga_context *svga ); @@ -612,6 +680,11 @@ svga_context( struct pipe_context *pipe ) return (struct svga_context *)pipe; } +static inline struct svga_winsys_screen * +svga_sws(struct svga_context *svga) +{ + return svga_screen(svga->pipe.screen)->sws; +} static inline boolean svga_have_gb_objects(const struct svga_context *svga) @@ -643,4 +716,15 @@ svga_rects_equal(const SVGA3dRect *r1, const SVGA3dRect *r2) return memcmp(r1, r2, sizeof(*r1)) == 0; } +/** + * If the Gallium HUD is enabled, this will return the current time. + * Otherwise, just return zero. + */ +static inline int64_t +svga_get_time(struct svga_context *svga) +{ + return svga->hud.uses_time ? os_time_get() : 0; +} + + #endif