X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=blobdiff_plain;f=src%2Famd%2Fcompiler%2Ftests%2Fhelpers.h;h=6fa8f41a5ee6dca6fbc75f728fba8e978de5b746;hp=50f5049795112a045b2f28c37bea938b7215c47f;hb=d488d0fd7baff77204dbd3fd0d625b5974728534;hpb=bb7d7755f56a85087b5b127e76d739f7f4eb9907 diff --git a/src/amd/compiler/tests/helpers.h b/src/amd/compiler/tests/helpers.h index 50f50497951..6fa8f41a5ee 100644 --- a/src/amd/compiler/tests/helpers.h +++ b/src/amd/compiler/tests/helpers.h @@ -25,6 +25,40 @@ #define ACO_TEST_HELPERS_H #include "framework.h" +#include "vulkan/vulkan.h" + +enum QoShaderDeclType { + QoShaderDeclType_ubo, + QoShaderDeclType_ssbo, + QoShaderDeclType_img_buf, + QoShaderDeclType_img, + QoShaderDeclType_tex_buf, + QoShaderDeclType_combined, + QoShaderDeclType_tex, + QoShaderDeclType_samp, + QoShaderDeclType_in, + QoShaderDeclType_out, +}; + +struct QoShaderDecl { + const char *name; + const char *type; + QoShaderDeclType decl_type; + //TODO: array size? + unsigned location; + unsigned component; + unsigned binding; + unsigned set; +}; + +struct QoShaderModuleCreateInfo { + void *pNext; + size_t spirvSize; + const void *pSpirv; + uint32_t declarationCount; + const QoShaderDecl *pDeclarations; + VkShaderStageFlagBits stage; +}; extern ac_shader_config config; extern radv_shader_info info; @@ -47,4 +81,73 @@ void finish_assembler_test(); void writeout(unsigned i, aco::Temp tmp=aco::Temp(0, aco::s1)); +/* vulkan helpers */ +VkDevice get_vk_device(enum chip_class chip_class); +VkDevice get_vk_device(enum radeon_family family); + +void print_pipeline_ir(VkDevice device, VkPipeline pipeline, VkShaderStageFlagBits stages, + const char *name, bool remove_encoding=false); + +VkShaderModule __qoCreateShaderModule(VkDevice dev, const QoShaderModuleCreateInfo *info); + +class PipelineBuilder { +public: + /* inputs */ + VkDevice device; + VkFormat color_outputs[16]; + VkFormat ds_output; + VkPrimitiveTopology topology; + VkSampleCountFlagBits samples; + bool sample_shading_enable; + float min_sample_shading; + uint32_t patch_size; + VkPipelineVertexInputStateCreateInfo vs_input; + VkVertexInputBindingDescription vs_bindings[16]; + VkVertexInputAttributeDescription vs_attributes[16]; + VkPushConstantRange push_constant_range; + uint64_t desc_layouts_used; + unsigned num_desc_bindings[64]; + VkDescriptorSetLayoutBinding desc_bindings[64][64]; + VkPipelineShaderStageCreateInfo stages[5]; + VkShaderStageFlags owned_stages; + + /* outputs */ + VkGraphicsPipelineCreateInfo gfx_pipeline_info; + VkComputePipelineCreateInfo cs_pipeline_info; + VkDescriptorSetLayout desc_layouts[64]; + VkPipelineLayout pipeline_layout; + VkRenderPass render_pass; + VkPipeline pipeline; + + PipelineBuilder(VkDevice dev); + ~PipelineBuilder(); + + PipelineBuilder(const PipelineBuilder&) = delete; + PipelineBuilder& operator = (const PipelineBuilder&) = delete; + + void add_desc_binding(VkShaderStageFlags stage_flags, uint32_t layout, + uint32_t binding, VkDescriptorType type, uint32_t count=1); + + void add_vertex_binding(uint32_t binding, uint32_t stride, VkVertexInputRate rate=VK_VERTEX_INPUT_RATE_VERTEX); + void add_vertex_attribute(uint32_t location, uint32_t binding, VkFormat format, uint32_t offset); + + void add_resource_decls(QoShaderModuleCreateInfo *module); + void add_io_decls(QoShaderModuleCreateInfo *module); + + void add_stage(VkShaderStageFlagBits stage, VkShaderModule module, const char *name="main"); + void add_vsfs(VkShaderModule vs, VkShaderModule fs); + void add_vsfs(QoShaderModuleCreateInfo vs, QoShaderModuleCreateInfo fs); + void add_cs(VkShaderModule cs); + void add_cs(QoShaderModuleCreateInfo cs); + + bool is_compute(); + + void create_pipeline(); + + void print_ir(VkShaderStageFlagBits stages, const char *name, bool remove_encoding=false); +private: + void create_compute_pipeline(); + void create_graphics_pipeline(); +}; + #endif /* ACO_TEST_HELPERS_H */