diff options
Diffstat (limited to 'lib/mesa/src/gallium/drivers/svga/svga_context.h')
-rw-r--r-- | lib/mesa/src/gallium/drivers/svga/svga_context.h | 218 |
1 files changed, 205 insertions, 13 deletions
diff --git a/lib/mesa/src/gallium/drivers/svga/svga_context.h b/lib/mesa/src/gallium/drivers/svga/svga_context.h index d5ef4c345..0227d64cf 100644 --- a/lib/mesa/src/gallium/drivers/svga/svga_context.h +++ b/lib/mesa/src/gallium/drivers/svga/svga_context.h @@ -43,6 +43,8 @@ #include "svga_winsys.h" #include "svga_hw_reg.h" #include "svga3d_shaderdefs.h" +#include "svga_image_view.h" +#include "svga_shader_buffer.h" #include "svga_debug.h" /** Non-GPU queries for gallium HUD */ @@ -83,10 +85,12 @@ enum svga_hud { SVGA_QUERY_MAX }; + /** * Maximum supported number of constant buffers per shader + * including the zero slot for the default constant buffer. */ -#define SVGA_MAX_CONST_BUFS 14 +#define SVGA_MAX_CONST_BUFS 15 /** * Maximum constant buffer size that can be set in the @@ -96,6 +100,18 @@ enum svga_hud { #define SVGA_MAX_CONST_BUF_SIZE (4096 * 4 * sizeof(int)) #define CONST0_UPLOAD_ALIGNMENT 256 +#define SVGA_MAX_IMAGES SVGA3D_MAX_UAVIEWS +#define SVGA_MAX_SHADER_BUFFERS SVGA3D_MAX_UAVIEWS +#define SVGA_MAX_ATOMIC_BUFFERS SVGA3D_MAX_UAVIEWS +#define SVGA_MAX_UAVIEWS SVGA3D_DX11_1_MAX_UAVIEWS + +enum svga_surface_state +{ + SVGA_SURFACE_STATE_CREATED, + SVGA_SURFACE_STATE_INVALIDATED, + SVGA_SURFACE_STATE_UPDATED, + SVGA_SURFACE_STATE_RENDERED, +}; struct draw_vertex_shader; struct draw_fragment_shader; @@ -169,6 +185,8 @@ struct svga_depth_stencil_state { #define SVGA_PIPELINE_FLAG_LINES (1<<PIPE_PRIM_LINES) #define SVGA_PIPELINE_FLAG_TRIS (1<<PIPE_PRIM_TRIANGLES) +#define SVGA_MAX_FRAMEBUFFER_DEFAULT_SAMPLES 4 + struct svga_rasterizer_state { struct pipe_rasterizer_state templ; /* needed for draw module */ @@ -194,6 +212,11 @@ struct svga_rasterizer_state { SVGA3dRasterizerStateId id; /**< vgpu10 */ + /* Alternate SVGA rasterizer state object with forcedSampleCount */ + int altRastIds[SVGA_MAX_FRAMEBUFFER_DEFAULT_SAMPLES+1]; + + struct svga_rasterizer_state *no_cull_rasterizer; + /** For debugging: */ const char* need_pipeline_tris_str; const char* need_pipeline_lines_str; @@ -263,6 +286,14 @@ struct svga_constant_buffer { unsigned size; }; +struct svga_raw_buffer { + struct svga_winsys_surface *handle; + unsigned buffer_offset; + unsigned buffer_size; + struct pipe_resource *buffer; + int32 srvid; +}; + /* Use to calculate differences between state emitted to hardware and * current driver-calculated state. */ @@ -270,10 +301,10 @@ struct svga_state { const struct svga_blend_state *blend; const struct svga_depth_stencil_state *depth; - const struct svga_rasterizer_state *rast; const struct svga_sampler_state *sampler[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; const struct svga_velems_state *velems; + struct svga_rasterizer_state *rast; struct pipe_sampler_view *sampler_views[PIPE_SHADER_TYPES][PIPE_MAX_SAMPLERS]; /* or texture ID's? */ struct svga_fragment_shader *fs; struct svga_vertex_shader *vs; @@ -291,6 +322,7 @@ struct svga_state * svga_shader_emitter_v10.num_shader_consts. */ struct pipe_constant_buffer constbufs[PIPE_SHADER_TYPES][SVGA_MAX_CONST_BUFS]; + struct svga_raw_buffer rawbufs[PIPE_SHADER_TYPES][SVGA_MAX_CONST_BUFS]; struct pipe_framebuffer_state framebuffer; float depthscale; @@ -322,12 +354,26 @@ struct svga_state unsigned sample_mask; unsigned vertices_per_patch; float default_tesslevels[6]; /* tessellation (outer[4] + inner[2]) levels */ + + /* Image views */ + unsigned num_image_views[PIPE_SHADER_TYPES]; + struct svga_image_view image_views[PIPE_SHADER_TYPES][SVGA_MAX_IMAGES]; + + /* Shader buffers */ + unsigned num_shader_buffers[PIPE_SHADER_TYPES]; + struct svga_shader_buffer shader_buffers[PIPE_SHADER_TYPES][SVGA_MAX_SHADER_BUFFERS]; + + /* HW atomic buffers */ + unsigned num_atomic_buffers; + struct svga_shader_buffer atomic_buffers[SVGA_MAX_SHADER_BUFFERS]; + struct { /* Determine the layout of the grid (in block units) to be used. */ unsigned size[3]; /* If DispatchIndirect is used, this will has grid size info*/ struct pipe_resource *indirect; } grid_info; + }; struct svga_prescale { @@ -399,6 +445,8 @@ struct svga_hw_draw_state /** Currently bound constant buffer, per shader stage */ struct pipe_resource *constbuf[PIPE_SHADER_TYPES][SVGA_MAX_CONST_BUFS]; struct svga_constant_buffer constbufoffsets[PIPE_SHADER_TYPES][SVGA_MAX_CONST_BUFS]; + struct svga_raw_buffer rawbufs[PIPE_SHADER_TYPES][SVGA_MAX_CONST_BUFS]; + unsigned enabled_rawbufs[PIPE_SHADER_TYPES]; /** Bitmask of enabled constant buffers */ unsigned enabled_constbufs[PIPE_SHADER_TYPES]; @@ -421,7 +469,7 @@ struct svga_hw_draw_state SVGA3dPrimitiveType topology; /** Vertex buffer state */ - SVGA3dVertexBuffer vbuffer_attrs[PIPE_MAX_ATTRIBS]; + SVGA3dVertexBuffer_v2 vbuffer_attrs[PIPE_MAX_ATTRIBS]; struct pipe_resource *vbuffers[PIPE_MAX_ATTRIBS]; unsigned num_vbuffers; @@ -441,6 +489,35 @@ struct svga_hw_draw_state boolean rasterizer_discard; /* set if rasterization is disabled */ boolean has_backed_views; /* set if any of the rtv/dsv is a backed surface view */ + + /* Image Views */ + int uavSpliceIndex; + unsigned num_image_views[PIPE_SHADER_TYPES]; + struct svga_image_view image_views[PIPE_SHADER_TYPES][SVGA_MAX_IMAGES]; + + /* Shader Buffers */ + unsigned num_shader_buffers[PIPE_SHADER_TYPES]; + struct svga_shader_buffer shader_buffers[PIPE_SHADER_TYPES][SVGA_MAX_SHADER_BUFFERS]; + + /* HW Atomic Buffers */ + unsigned num_atomic_buffers; + struct svga_shader_buffer atomic_buffers[SVGA_MAX_SHADER_BUFFERS]; + + /* UAV state */ + unsigned num_uavs; + SVGA3dUAViewId uaViewIds[SVGA_MAX_UAVIEWS]; + struct svga_winsys_surface *uaViews[SVGA_MAX_UAVIEWS]; + + /* Compute UAV state */ + unsigned num_cs_uavs; + SVGA3dUAViewId csUAViewIds[SVGA_MAX_UAVIEWS]; + struct svga_winsys_surface *csUAViews[SVGA_MAX_UAVIEWS]; + + /* starting uav index for each shader */ + unsigned uav_start_index[PIPE_SHADER_TYPES]; + + /* starting uav index for HW atomic buffers */ + unsigned uav_atomic_buf_index; }; @@ -468,6 +545,32 @@ struct svga_hw_queue; struct svga_query; struct svga_qmem_alloc_entry; +enum svga_uav_type +{ + SVGA_IMAGE_VIEW = 0, + SVGA_SHADER_BUFFER +}; + +struct svga_uav +{ + enum svga_uav_type type; + union { + struct svga_image_view image_view; + struct svga_shader_buffer shader_buffer; + } desc; + struct pipe_resource *resource; + unsigned next_uaView; + SVGA3dUAViewId uaViewId; + unsigned timestamp[2]; +}; + +struct svga_cache_uav +{ + unsigned num_uaViews; + unsigned next_uaView; + struct svga_uav uaViews[SVGA3D_DX11_1_MAX_UAVIEWS]; +}; + struct svga_context { struct pipe_context pipe; @@ -488,7 +591,7 @@ struct svga_context boolean force_hw_line_stipple; /** To report perf/conformance/etc issues to the gallium frontend */ - struct pipe_debug_callback callback; + struct util_debug_callback callback; } debug; struct { @@ -517,6 +620,9 @@ struct svga_context /* Bitmask of sampler view IDs */ struct util_bitmask *sampler_view_id_bm; + /* Bitmask of to-free sampler view IDs created for raw buffer srv */ + struct util_bitmask *sampler_view_to_free_id_bm; + /* Bitmask of used shader IDs */ struct util_bitmask *shader_id_bm; @@ -529,13 +635,23 @@ struct svga_context /* Bitmask of used query IDs */ struct util_bitmask *query_id_bm; + /* Bitmask of used uav IDs */ + struct util_bitmask *uav_id_bm; + + /* Bitmask of to-free uav IDs */ + struct util_bitmask *uav_to_free_id_bm; + struct { uint64_t dirty[SVGA_STATE_MAX]; /** bitmasks of which const buffers are changed */ unsigned dirty_constbufs[PIPE_SHADER_TYPES]; + /** bitmasks of which const buffers to be bound as raw buffers */ + unsigned raw_constbufs[PIPE_SHADER_TYPES]; + unsigned texture_timestamp; + unsigned uav_timestamp[2]; struct svga_sw_state sw; struct svga_hw_draw_state hw_draw; @@ -557,6 +673,12 @@ struct svga_context unsigned tes:1; unsigned cs:1; unsigned query:1; + unsigned images:1; + unsigned shaderbufs:1; + unsigned atomicbufs:1; + unsigned uav:1; + unsigned indexbuf:1; + unsigned vertexbufs:1; } flags; unsigned val; } rebind; @@ -641,9 +763,6 @@ struct svga_context void *sampler; } polygon_stipple; - /** Alternate rasterizer states created for point sprite */ - struct svga_rasterizer_state *rasterizer_no_cull[2]; - /** Depth stencil state created to disable depth stencil test */ struct svga_depth_stencil_state *depthstencil_disable; @@ -665,6 +784,8 @@ struct svga_context boolean passthrough; } tcs; + struct svga_cache_uav cache_uav; + struct pipe_resource *dummy_resource; }; /* A flag for each frontend state object: @@ -707,19 +828,38 @@ struct svga_context #define SVGA_NEW_TCS_CONST_BUFFER ((uint64_t) 0x1000000000) #define SVGA_NEW_TES_CONST_BUFFER ((uint64_t) 0x2000000000) #define SVGA_NEW_TCS_PARAM ((uint64_t) 0x4000000000) -#define SVGA_NEW_FS_CONSTS ((uint64_t) 0x8000000000) -#define SVGA_NEW_VS_CONSTS ((uint64_t) 0x10000000000) -#define SVGA_NEW_GS_CONSTS ((uint64_t) 0x20000000000) -#define SVGA_NEW_TCS_CONSTS ((uint64_t) 0x40000000000) -#define SVGA_NEW_TES_CONSTS ((uint64_t) 0x800000000000) +#define SVGA_NEW_IMAGE_VIEW ((uint64_t) 0x8000000000) +#define SVGA_NEW_SHADER_BUFFER ((uint64_t) 0x10000000000) +#define SVGA_NEW_CS ((uint64_t) 0x20000000000) +#define SVGA_NEW_CS_VARIANT ((uint64_t) 0x40000000000) +#define SVGA_NEW_CS_CONST_BUFFER ((uint64_t) 0x80000000000) +#define SVGA_NEW_FS_CONSTS ((uint64_t) 0x100000000000) +#define SVGA_NEW_VS_CONSTS ((uint64_t) 0x200000000000) +#define SVGA_NEW_GS_CONSTS ((uint64_t) 0x400000000000) +#define SVGA_NEW_TCS_CONSTS ((uint64_t) 0x800000000000) +#define SVGA_NEW_TES_CONSTS ((uint64_t) 0x1000000000000) +#define SVGA_NEW_CS_CONSTS ((uint64_t) 0x2000000000000) +#define SVGA_NEW_FS_RAW_BUFFER ((uint64_t) 0x4000000000000) +#define SVGA_NEW_VS_RAW_BUFFER ((uint64_t) 0x8000000000000) +#define SVGA_NEW_GS_RAW_BUFFER ((uint64_t) 0x10000000000000) +#define SVGA_NEW_TCS_RAW_BUFFER ((uint64_t) 0x20000000000000) +#define SVGA_NEW_TES_RAW_BUFFER ((uint64_t) 0x40000000000000) +#define SVGA_NEW_CS_RAW_BUFFER ((uint64_t) 0x80000000000000) #define SVGA_NEW_ALL ((uint64_t) 0xFFFFFFFFFFFFFFFF) #define SVGA_NEW_CONST_BUFFER \ (SVGA_NEW_FS_CONST_BUFFER | SVGA_NEW_VS_CONST_BUFFER | \ - SVGA_NEW_GS_CONST_BUFFER | \ + SVGA_NEW_GS_CONST_BUFFER | SVGA_NEW_CS_CONST_BUFFER | \ SVGA_NEW_TCS_CONST_BUFFER | SVGA_NEW_TES_CONST_BUFFER) +/** Program pipelines */ +enum svga_pipe_type +{ + SVGA_PIPE_GRAPHICS = 0, + SVGA_PIPE_COMPUTE = 1 +}; + void svga_init_state_functions( struct svga_context *svga ); void svga_init_flush_functions( struct svga_context *svga ); void svga_init_string_functions( struct svga_context *svga ); @@ -742,6 +882,7 @@ 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_init_shader_image_functions( struct svga_context *svga ); void svga_cleanup_vertex_state( struct svga_context *svga ); void svga_cleanup_sampler_state( struct svga_context *svga ); @@ -769,6 +910,36 @@ void svga_toggle_render_condition(struct svga_context *svga, boolean render_condition_enabled, boolean on); +int svga_define_rasterizer_object(struct svga_context *svga, + struct svga_rasterizer_state *, + unsigned samples); + +enum pipe_error +svga_validate_sampler_resources(struct svga_context *svga, + enum svga_pipe_type); + +enum pipe_error +svga_validate_constant_buffers(struct svga_context *svga, + enum svga_pipe_type); + +enum pipe_error +svga_validate_image_views(struct svga_context *svga, + enum svga_pipe_type); + +enum pipe_error +svga_validate_shader_buffers(struct svga_context *svga, + enum svga_pipe_type); + +void +svga_destroy_rawbuf_srv(struct svga_context *svga); + +void +svga_uav_cache_init(struct svga_context *svga); + +void +svga_destroy_rawbuf_srv(struct svga_context *svga); + + /*********************************************************************** * Inline conversion functions. These are better-typed than the * macros used previously: @@ -816,6 +987,12 @@ svga_have_sm5(const struct svga_context *svga) } static inline boolean +svga_have_gl43(const struct svga_context *svga) +{ + return svga_screen(svga->pipe.screen)->sws->have_gl43; +} + +static inline boolean svga_need_to_rebind_resources(const struct svga_context *svga) { return svga_screen(svga->pipe.screen)->sws->need_to_rebind_resources; @@ -827,6 +1004,21 @@ svga_rects_equal(const SVGA3dRect *r1, const SVGA3dRect *r2) return memcmp(r1, r2, sizeof(*r1)) == 0; } + +/* A helper function to return TRUE if sampler state mapping is + * to be used. Sampler state mapping is used in GL43 context + * if the number of sampler states exceeds the SVGA device limit or + * the sampler state mapping environment variable is set. + */ +static inline boolean +svga_use_sampler_state_mapping(const struct svga_context *svga, + unsigned num_sampler_states) +{ + return svga_have_gl43(svga) && + (svga_screen(svga->pipe.screen)->debug.sampler_state_mapping || + num_sampler_states > SVGA3D_DX_MAX_SAMPLERS); +} + /** * If the Gallium HUD is enabled, this will return the current time. * Otherwise, just return zero. |