2020-01-22 19:58:27 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2020 Valve Corporation
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
|
* Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#ifndef ACO_TEST_HELPERS_H
|
|
|
|
|
#define ACO_TEST_HELPERS_H
|
|
|
|
|
|
|
|
|
|
#include "framework.h"
|
2020-02-14 11:32:18 +00:00
|
|
|
#include "vulkan/vulkan.h"
|
2022-09-20 16:28:01 +02:00
|
|
|
#include <functional>
|
2020-02-14 11:32:18 +00:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
};
|
2020-01-22 19:58:27 +00:00
|
|
|
|
|
|
|
|
extern ac_shader_config config;
|
2022-05-05 13:34:41 +10:00
|
|
|
extern aco_shader_info info;
|
2020-01-22 19:58:27 +00:00
|
|
|
extern std::unique_ptr<aco::Program> program;
|
|
|
|
|
extern aco::Builder bld;
|
|
|
|
|
extern aco::Temp inputs[16];
|
|
|
|
|
|
2020-11-02 18:16:56 +01:00
|
|
|
namespace aco {
|
|
|
|
|
struct ra_test_policy;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-12 02:50:17 -04:00
|
|
|
void create_program(enum amd_gfx_level gfx_level, aco::Stage stage,
|
2020-01-22 19:58:27 +00:00
|
|
|
unsigned wave_size=64, enum radeon_family family=CHIP_UNKNOWN);
|
2022-05-12 02:50:17 -04:00
|
|
|
bool setup_cs(const char *input_spec, enum amd_gfx_level gfx_level,
|
2020-11-05 12:43:14 +01:00
|
|
|
enum radeon_family family=CHIP_UNKNOWN, const char* subvariant = "",
|
|
|
|
|
unsigned wave_size=64);
|
2020-01-22 19:58:27 +00:00
|
|
|
|
|
|
|
|
void finish_program(aco::Program *program);
|
|
|
|
|
void finish_validator_test();
|
|
|
|
|
void finish_opt_test();
|
2023-01-27 19:56:56 +00:00
|
|
|
void finish_setup_reduce_temp_test();
|
2021-06-16 15:35:36 +01:00
|
|
|
void finish_ra_test(aco::ra_test_policy, bool lower=false);
|
2020-11-24 11:39:28 +01:00
|
|
|
void finish_optimizer_postRA_test();
|
2020-01-22 19:58:27 +00:00
|
|
|
void finish_to_hw_instr_test();
|
2022-10-27 12:49:09 +01:00
|
|
|
void finish_waitcnt_test();
|
2021-02-23 09:54:04 +00:00
|
|
|
void finish_insert_nops_test();
|
2021-05-20 10:41:37 +01:00
|
|
|
void finish_form_hard_clause_test();
|
2020-01-22 19:58:27 +00:00
|
|
|
void finish_assembler_test();
|
|
|
|
|
|
|
|
|
|
void writeout(unsigned i, aco::Temp tmp=aco::Temp(0, aco::s1));
|
2020-12-04 16:18:44 +01:00
|
|
|
void writeout(unsigned i, aco::Builder::Result res);
|
|
|
|
|
void writeout(unsigned i, aco::Operand op);
|
|
|
|
|
void writeout(unsigned i, aco::Operand op0, aco::Operand op1);
|
2020-01-22 19:58:27 +00:00
|
|
|
|
2022-01-27 14:17:23 +00:00
|
|
|
aco::Temp fneg(aco::Temp src, aco::Builder b=bld);
|
|
|
|
|
aco::Temp fabs(aco::Temp src, aco::Builder b=bld);
|
|
|
|
|
aco::Temp f2f32(aco::Temp src, aco::Builder b=bld);
|
|
|
|
|
aco::Temp f2f16(aco::Temp src, aco::Builder b=bld);
|
|
|
|
|
aco::Temp u2u16(aco::Temp src, aco::Builder b=bld);
|
|
|
|
|
aco::Temp fadd(aco::Temp src0, aco::Temp src1, aco::Builder b=bld);
|
|
|
|
|
aco::Temp fmul(aco::Temp src0, aco::Temp src1, aco::Builder b=bld);
|
|
|
|
|
aco::Temp fma(aco::Temp src0, aco::Temp src1, aco::Temp src2, aco::Builder b=bld);
|
|
|
|
|
aco::Temp fsat(aco::Temp src, aco::Builder b=bld);
|
aco: use v_minmax/v_maxmin opcodes
fossil-db (gfx1100):
Totals from 29868 (22.12% of 135032) affected shaders:
MaxWaves: 741336 -> 741344 (+0.00%)
Instrs: 34624902 -> 34539766 (-0.25%); split: -0.25%, +0.00%
CodeSize: 187196804 -> 187192100 (-0.00%); split: -0.01%, +0.01%
VGPRs: 1816860 -> 1816788 (-0.00%); split: -0.01%, +0.01%
Latency: 502597202 -> 502245627 (-0.07%); split: -0.08%, +0.01%
InvThroughput: 84813176 -> 84586122 (-0.27%); split: -0.28%, +0.01%
VClause: 633826 -> 633749 (-0.01%); split: -0.02%, +0.01%
SClause: 1317738 -> 1317047 (-0.05%); split: -0.06%, +0.01%
Copies: 2130610 -> 2130954 (+0.02%); split: -0.03%, +0.05%
Branches: 766093 -> 765969 (-0.02%); split: -0.02%, +0.00%
PreSGPRs: 1630250 -> 1630034 (-0.01%); split: -0.02%, +0.00%
PreVGPRs: 1590777 -> 1590664 (-0.01%); split: -0.01%, +0.00%
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19933>
2022-11-16 17:42:20 +00:00
|
|
|
aco::Temp fmin(aco::Temp src0, aco::Temp src1, aco::Builder b=bld);
|
|
|
|
|
aco::Temp fmax(aco::Temp src0, aco::Temp src1, aco::Builder b=bld);
|
2022-01-27 14:17:23 +00:00
|
|
|
aco::Temp ext_ushort(aco::Temp src, unsigned idx, aco::Builder b=bld);
|
|
|
|
|
aco::Temp ext_ubyte(aco::Temp src, unsigned idx, aco::Builder b=bld);
|
2022-09-20 16:28:01 +02:00
|
|
|
void emit_divergent_if_else(aco::Program* prog, aco::Builder& b, aco::Operand cond, std::function<void()> then,
|
|
|
|
|
std::function<void()> els);
|
2020-02-03 15:22:11 +00:00
|
|
|
|
2020-02-14 11:32:18 +00:00
|
|
|
/* vulkan helpers */
|
2022-05-12 02:50:17 -04:00
|
|
|
VkDevice get_vk_device(enum amd_gfx_level gfx_level);
|
2020-02-14 11:32:18 +00:00
|
|
|
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");
|
2020-11-12 14:21:00 +00:00
|
|
|
void add_stage(VkShaderStageFlagBits stage, QoShaderModuleCreateInfo module, const char *name="main");
|
2020-02-14 11:32:18 +00:00
|
|
|
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();
|
|
|
|
|
};
|
|
|
|
|
|
2020-01-22 19:58:27 +00:00
|
|
|
#endif /* ACO_TEST_HELPERS_H */
|