X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fvulkan%2Fanv_private.h;h=03d033ff0c5d8cb405c88d5b89e316efd4cebf80;hb=3ee923f1c2ef0832ebd6da445548e0a651aaae80;hp=0d1998d659ca30b48652a6a541c055fe1a7af080;hpb=1a52bc30390d56493ea2d0a950d8b9f01519ed24;p=mesa.git diff --git a/src/vulkan/anv_private.h b/src/vulkan/anv_private.h index 0d1998d659c..03d033ff0c5 100644 --- a/src/vulkan/anv_private.h +++ b/src/vulkan/anv_private.h @@ -46,8 +46,8 @@ #define VK_PROTOTYPES #include #include -#include -#include +#include +#include #include "anv_entrypoints.h" @@ -164,6 +164,16 @@ void anv_loge_v(const char *format, va_list va); #define anv_assert(x) #endif +/** + * If a block of code is annotated with anv_validate, then the block runs only + * in debug builds. + */ +#ifdef DEBUG +#define anv_validate if (1) +#else +#define anv_validate if (0) +#endif + void anv_abortf(const char *format, ...) anv_noreturn anv_printflike(1, 2); void anv_abortfv(const char *format, va_list va) anv_noreturn; @@ -417,8 +427,12 @@ struct anv_physical_device { const char * name; const struct brw_device_info * info; uint64_t aperture_size; + struct brw_compiler * compiler; }; +bool anv_is_scalar_shader_stage(const struct brw_compiler *compiler, + VkShaderStage stage); + struct anv_instance { VK_LOADER_DATA _loader_data; @@ -426,10 +440,10 @@ struct anv_instance { PFN_vkAllocFunction pfnAlloc; PFN_vkFreeFunction pfnFree; uint32_t apiVersion; - uint32_t physicalDeviceCount; + int physicalDeviceCount; struct anv_physical_device physicalDevice; - struct anv_wsi_implementation * wsi_impl[VK_PLATFORM_NUM_WSI]; + struct anv_wsi_implementation * wsi_impl[VK_PLATFORM_NUM_KHR]; }; VkResult anv_init_wsi(struct anv_instance *instance); @@ -437,10 +451,15 @@ void anv_finish_wsi(struct anv_instance *instance); struct anv_meta_state { struct { - VkPipeline pipeline; + struct anv_pipeline *color_pipeline; + struct anv_pipeline *depth_only_pipeline; + struct anv_pipeline *stencil_only_pipeline; + struct anv_pipeline *depthstencil_pipeline; } clear; struct { + VkRenderPass render_pass; + /** Pipeline that blits from a 2D image. */ VkPipeline pipeline_2d_src; @@ -458,20 +477,6 @@ struct anv_queue { struct anv_device * device; struct anv_state_pool * pool; - - /** - * Serial number of the most recently completed batch executed on the - * engine. - */ - struct anv_state completed_serial; - - /** - * The next batch submitted to the engine will be assigned this serial - * number. - */ - uint32_t next_serial; - - uint32_t last_collected_serial; }; struct anv_device { @@ -500,7 +505,6 @@ struct anv_device { struct anv_block_pool scratch_block_pool; - struct anv_compiler * compiler; pthread_mutex_t mutex; }; @@ -674,43 +678,76 @@ struct anv_device_memory { void * map; }; -struct anv_descriptor_slot { - int8_t dynamic_slot; - uint8_t index; +/** + * Header for Vertex URB Entry (VUE) + */ +struct anv_vue_header { + uint32_t Reserved; + uint32_t RTAIndex; /* RenderTargetArrayIndex */ + uint32_t ViewportIndex; + float PointWidth; }; -struct anv_descriptor_set_layout { +struct anv_descriptor_set_binding_layout { + /* Number of array elements in this binding */ + uint16_t array_size; + + /* Index into the flattend descriptor set */ + uint16_t descriptor_index; + + /* Index into the dynamic state array for a dynamic buffer */ + int16_t dynamic_offset_index; + struct { - uint32_t surface_count; - struct anv_descriptor_slot *surface_start; - uint32_t sampler_count; - struct anv_descriptor_slot *sampler_start; + /* Index into the binding table for the associated surface */ + int16_t surface_index; + + /* Index into the sampler table for the associated sampler */ + int16_t sampler_index; } stage[VK_SHADER_STAGE_NUM]; - uint32_t count; - uint32_t num_dynamic_buffers; - VkShaderStageFlags shader_stages; - struct anv_descriptor_slot entries[0]; + /* Immutable samplers (or NULL if no immutable samplers) */ + struct anv_sampler **immutable_samplers; }; -enum anv_descriptor_type { - ANV_DESCRIPTOR_TYPE_EMPTY = 0, - ANV_DESCRIPTOR_TYPE_BUFFER_VIEW, - ANV_DESCRIPTOR_TYPE_IMAGE_VIEW, - ANV_DESCRIPTOR_TYPE_SAMPLER, +struct anv_descriptor_set_layout { + /* Number of bindings in this descriptor set */ + uint16_t binding_count; + + /* Total size of the descriptor set with room for all array entries */ + uint16_t size; + + /* Shader stages affected by this descriptor set */ + uint16_t shader_stages; + + /* Number of dynamic offsets used by this descriptor set */ + uint16_t dynamic_offset_count; + + /* Bindings in this descriptor set */ + struct anv_descriptor_set_binding_layout binding[0]; }; struct anv_descriptor { + VkDescriptorType type; + union { - struct anv_buffer_view *buffer_view; - struct anv_image_view *image_view; - struct anv_sampler *sampler; - }; + struct { + union { + struct anv_image_view *image_view; + }; + struct anv_sampler *sampler; + }; - enum anv_descriptor_type type; + struct { + struct anv_buffer *buffer; + uint64_t offset; + uint64_t range; + }; + }; }; struct anv_descriptor_set { + const struct anv_descriptor_set_layout *layout; struct anv_descriptor descriptors[0]; }; @@ -732,6 +769,14 @@ anv_descriptor_set_destroy(struct anv_device *device, #define MAX_DYNAMIC_BUFFERS 16 #define MAX_IMAGES 8 +struct anv_pipeline_binding { + /* The descriptor set this surface corresponds to */ + uint16_t set; + + /* Offset into the descriptor set */ + uint16_t offset; +}; + struct anv_pipeline_layout { struct { struct anv_descriptor_set_layout *layout; @@ -747,8 +792,12 @@ struct anv_pipeline_layout { struct { bool has_dynamic_offsets; uint32_t surface_count; + struct anv_pipeline_binding *surface_to_descriptor; uint32_t sampler_count; + struct anv_pipeline_binding *sampler_to_descriptor; } stage[VK_SHADER_STAGE_NUM]; + + struct anv_pipeline_binding entries[0]; }; struct anv_buffer { @@ -760,29 +809,27 @@ struct anv_buffer { VkDeviceSize offset; }; -/* The first 9 correspond to 1 << VK_DYNAMIC_STATE_FOO */ -#define ANV_DYNAMIC_VIEWPORT_DIRTY (1 << 0) -#define ANV_DYNAMIC_SCISSOR_DIRTY (1 << 1) -#define ANV_DYNAMIC_LINE_WIDTH_DIRTY (1 << 2) -#define ANV_DYNAMIC_DEPTH_BIAS_DIRTY (1 << 3) -#define ANV_DYNAMIC_BLEND_CONSTANTS_DIRTY (1 << 4) -#define ANV_DYNAMIC_DEPTH_BOUNDS_DIRTY (1 << 5) -#define ANV_DYNAMIC_STENCIL_COMPARE_MASK_DIRTY (1 << 6) -#define ANV_DYNAMIC_STENCIL_WRITE_MASK_DIRTY (1 << 7) -#define ANV_DYNAMIC_STENCIL_REFERENCE_DIRTY (1 << 8) -#define ANV_CMD_BUFFER_PIPELINE_DIRTY (1 << 9) -#define ANV_CMD_BUFFER_INDEX_BUFFER_DIRTY (1 << 10) +enum anv_cmd_dirty_bits { + ANV_CMD_DIRTY_DYNAMIC_VIEWPORT = 1 << 0, /* VK_DYNAMIC_STATE_VIEWPORT */ + ANV_CMD_DIRTY_DYNAMIC_SCISSOR = 1 << 1, /* VK_DYNAMIC_STATE_SCISSOR */ + ANV_CMD_DIRTY_DYNAMIC_LINE_WIDTH = 1 << 2, /* VK_DYNAMIC_STATE_LINE_WIDTH */ + ANV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS = 1 << 3, /* VK_DYNAMIC_STATE_DEPTH_BIAS */ + ANV_CMD_DIRTY_DYNAMIC_BLEND_CONSTANTS = 1 << 4, /* VK_DYNAMIC_STATE_BLEND_CONSTANTS */ + ANV_CMD_DIRTY_DYNAMIC_DEPTH_BOUNDS = 1 << 5, /* VK_DYNAMIC_STATE_DEPTH_BOUNDS */ + ANV_CMD_DIRTY_DYNAMIC_STENCIL_COMPARE_MASK = 1 << 6, /* VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK */ + ANV_CMD_DIRTY_DYNAMIC_STENCIL_WRITE_MASK = 1 << 7, /* VK_DYNAMIC_STATE_STENCIL_WRITE_MASK */ + ANV_CMD_DIRTY_DYNAMIC_STENCIL_REFERENCE = 1 << 8, /* VK_DYNAMIC_STATE_STENCIL_REFERENCE */ + ANV_CMD_DIRTY_DYNAMIC_ALL = (1 << 9) - 1, + ANV_CMD_DIRTY_PIPELINE = 1 << 9, + ANV_CMD_DIRTY_INDEX_BUFFER = 1 << 10, +}; +typedef uint32_t anv_cmd_dirty_mask_t; struct anv_vertex_binding { struct anv_buffer * buffer; VkDeviceSize offset; }; -struct anv_descriptor_set_binding { - struct anv_descriptor_set * set; - uint32_t dynamic_offsets[128]; -}; - struct anv_push_constants { /* Current allocated size of this push constants data structure. * Because a decent chunk of it may not be used (images on SKL, for @@ -800,8 +847,11 @@ struct anv_push_constants { uint32_t base_vertex; uint32_t base_instance; - /* Offsets for dynamically bound buffers */ - uint32_t dynamic_offsets[MAX_DYNAMIC_BUFFERS]; + /* Offsets and ranges for dynamically bound buffers */ + struct { + uint32_t offset; + uint32_t range; + } dynamic[MAX_DYNAMIC_BUFFERS]; /* Image data for image_load_store on pre-SKL */ struct brw_image_param images[MAX_IMAGES]; @@ -859,8 +909,8 @@ void anv_dynamic_state_copy(struct anv_dynamic_state *dest, struct anv_cmd_state { uint32_t current_pipeline; uint32_t vb_dirty; - uint32_t dirty; - uint32_t compute_dirty; + anv_cmd_dirty_mask_t dirty; + anv_cmd_dirty_mask_t compute_dirty; VkShaderStageFlags descriptors_dirty; VkShaderStageFlags push_constants_dirty; uint32_t scratch_size; @@ -871,7 +921,7 @@ struct anv_cmd_state { struct anv_subpass * subpass; uint32_t state_vf[GEN8_3DSTATE_VF_length]; struct anv_vertex_binding vertex_bindings[MAX_VBS]; - struct anv_descriptor_set_binding descriptors[MAX_SETS]; + struct anv_descriptor_set * descriptors[MAX_SETS]; struct anv_push_constants * push_constants[VK_SHADER_STAGE_NUM]; struct anv_dynamic_state dynamic; @@ -985,6 +1035,8 @@ struct anv_state anv_cmd_buffer_alloc_binding_table(struct anv_cmd_buffer *cmd_buffer, uint32_t entries, uint32_t *state_offset); struct anv_state +anv_cmd_buffer_alloc_surface_state(struct anv_cmd_buffer *cmd_buffer); +struct anv_state anv_cmd_buffer_alloc_dynamic_state(struct anv_cmd_buffer *cmd_buffer, uint32_t size, uint32_t alignment); @@ -1044,12 +1096,11 @@ struct anv_shader { struct anv_pipeline { struct anv_device * device; struct anv_batch batch; - uint32_t batch_data[256]; + uint32_t batch_data[512]; struct anv_reloc_list batch_relocs; uint32_t dynamic_state_mask; struct anv_dynamic_state dynamic_state; - struct anv_shader * shaders[VK_SHADER_STAGE_NUM]; struct anv_pipeline_layout * layout; bool use_repclear; @@ -1120,6 +1171,11 @@ anv_pipeline_init(struct anv_pipeline *pipeline, struct anv_device *device, const VkGraphicsPipelineCreateInfo *pCreateInfo, const struct anv_graphics_pipeline_create_info *extra); +VkResult +anv_pipeline_compile_cs(struct anv_pipeline *pipeline, + const VkComputePipelineCreateInfo *info, + struct anv_shader *shader); + VkResult anv_graphics_pipeline_create(VkDevice device, const VkGraphicsPipelineCreateInfo *pCreateInfo, @@ -1147,16 +1203,11 @@ gen8_compute_pipeline_create(VkDevice _device, const VkComputePipelineCreateInfo *pCreateInfo, VkPipeline *pPipeline); -struct anv_compiler *anv_compiler_create(struct anv_device *device); -void anv_compiler_destroy(struct anv_compiler *compiler); -int anv_compiler_run(struct anv_compiler *compiler, struct anv_pipeline *pipeline); -void anv_compiler_free(struct anv_pipeline *pipeline); - struct anv_format { const VkFormat vk_format; const char *name; uint16_t surface_format; /**< RENDER_SURFACE_STATE.SurfaceFormat */ - uint8_t cpp; /**< Bytes-per-pixel of anv_format::surface_format. */ + uint8_t bs; /**< Block size (in bytes) of anv_format::surface_format. */ uint8_t num_channels; uint16_t depth_format; /**< 3DSTATE_DEPTH_BUFFER.SurfaceFormat */ bool has_stencil; @@ -1262,14 +1313,6 @@ struct anv_image { }; }; -struct anv_buffer_view { - struct anv_state surface_state; /**< RENDER_SURFACE_STATE */ - struct anv_bo *bo; - uint32_t offset; /**< Offset into bo. */ - uint32_t range; /**< VkBufferViewCreateInfo::range */ - const struct anv_format *format; /**< VkBufferViewCreateInfo::format */ -}; - struct anv_image_view { const struct anv_image *image; /**< VkImageViewCreateInfo::image */ const struct anv_format *format; /**< VkImageViewCreateInfo::format */ @@ -1316,18 +1359,17 @@ gen8_image_view_init(struct anv_image_view *iview, const VkImageViewCreateInfo* pCreateInfo, struct anv_cmd_buffer *cmd_buffer); -VkResult anv_buffer_view_create(struct anv_device *device, - const VkBufferViewCreateInfo *pCreateInfo, - struct anv_buffer_view **bview_out); - void anv_fill_buffer_surface_state(struct anv_device *device, void *state, const struct anv_format *format, - uint32_t offset, uint32_t range); + uint32_t offset, uint32_t range, + uint32_t stride); void gen7_fill_buffer_surface_state(void *state, const struct anv_format *format, - uint32_t offset, uint32_t range); + uint32_t offset, uint32_t range, + uint32_t stride); void gen8_fill_buffer_surface_state(void *state, const struct anv_format *format, - uint32_t offset, uint32_t range); + uint32_t offset, uint32_t range, + uint32_t stride); struct anv_sampler { uint32_t state[4]; @@ -1361,15 +1403,12 @@ struct anv_render_pass_attachment { struct anv_render_pass { uint32_t attachment_count; uint32_t subpass_count; - - uint32_t num_color_clear_attachments; - bool has_depth_clear_attachment; - bool has_stencil_clear_attachment; - struct anv_render_pass_attachment * attachments; struct anv_subpass subpasses[0]; }; +extern struct anv_render_pass anv_meta_dummy_renderpass; + struct anv_query_pool_slot { uint64_t begin; uint64_t end; @@ -1387,6 +1426,10 @@ void anv_device_finish_meta(struct anv_device *device); void *anv_lookup_entrypoint(const char *name); +void anv_dump_image_to_ppm(struct anv_device *device, + struct anv_image *image, unsigned miplevel, + unsigned array_layer, const char *filename); + #define ANV_DEFINE_HANDLE_CASTS(__anv_type, __VkType) \ \ static inline struct __anv_type * \ @@ -1426,7 +1469,6 @@ ANV_DEFINE_HANDLE_CASTS(anv_queue, VkQueue) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_cmd_pool, VkCmdPool) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer, VkBuffer) -ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_buffer_view, VkBufferView); ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set, VkDescriptorSet) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_descriptor_set_layout, VkDescriptorSetLayout) ANV_DEFINE_NONDISP_HANDLE_CASTS(anv_device_memory, VkDeviceMemory)