30
30
#include "qpu/qpu_disasm.h"
32
32
#include "compiler/nir/nir_builder.h"
33
#include "nir/nir_vulkan.h"
34
33
#include "nir/nir_serialize.h"
36
35
#include "util/u_atomic.h"
37
36
#include "util/u_prim.h"
38
37
#include "util/os_time.h"
39
#include "vk_nir_convert_ycbcr.h"
40
40
#include "vk_pipeline.h"
41
41
#include "vulkan/util/vk_format.h"
238
238
.max_unroll_iterations = 16,
239
239
.force_indirect_unrolling = (nir_var_shader_in | nir_var_function_temp),
240
240
.divergence_analysis_options =
241
nir_divergence_multiple_workgroup_per_compute_subgroup
241
nir_divergence_multiple_workgroup_per_compute_subgroup,
244
244
const nir_shader_compiler_options *
631
631
index = nir_iadd(b, index,
632
nir_imul(b, nir_imm_int(b, array_elements),
633
nir_ssa_for_src(b, deref->arr.index, 1)));
632
nir_imul_imm(b, nir_ssa_for_src(b, deref->arr.index, 1),
636
636
array_elements *= glsl_get_length(parent->type);
658
658
uint32_t set = deref->var->data.descriptor_set;
659
659
uint32_t binding = deref->var->data.binding;
660
660
/* FIXME: this is a really simplified check for the precision to be used
661
* for the sampling. Right now we are ony checking for the variables used
661
* for the sampling. Right now we are only checking for the variables used
662
662
* on the operation itself, but there are other cases that we could use to
663
663
* infer the precision requirement.
769
769
index = nir_iadd(b, index,
770
nir_imul(b, nir_imm_int(b, array_elements),
771
nir_ssa_for_src(b, deref->arr.index, 1)));
770
nir_imul_imm(b, nir_ssa_for_src(b, deref->arr.index, 1),
774
774
array_elements *= glsl_get_length(parent->type);
841
841
case nir_intrinsic_image_deref_load:
842
842
case nir_intrinsic_image_deref_store:
843
case nir_intrinsic_image_deref_atomic_add:
844
case nir_intrinsic_image_deref_atomic_imin:
845
case nir_intrinsic_image_deref_atomic_umin:
846
case nir_intrinsic_image_deref_atomic_imax:
847
case nir_intrinsic_image_deref_atomic_umax:
848
case nir_intrinsic_image_deref_atomic_and:
849
case nir_intrinsic_image_deref_atomic_or:
850
case nir_intrinsic_image_deref_atomic_xor:
851
case nir_intrinsic_image_deref_atomic_exchange:
852
case nir_intrinsic_image_deref_atomic_comp_swap:
843
case nir_intrinsic_image_deref_atomic:
844
case nir_intrinsic_image_deref_atomic_swap:
853
845
case nir_intrinsic_image_deref_size:
854
846
case nir_intrinsic_image_deref_samples:
855
847
lower_image_deref(b, instr, state);
1050
1042
/* FIXME: anv maps to hw primitive type. Perhaps eventually we would do the
1051
1043
* same. For not using prim_mode that is the one already used on v3d
1053
static const enum pipe_prim_type vk_to_pipe_prim_type[] = {
1054
[VK_PRIMITIVE_TOPOLOGY_POINT_LIST] = PIPE_PRIM_POINTS,
1055
[VK_PRIMITIVE_TOPOLOGY_LINE_LIST] = PIPE_PRIM_LINES,
1056
[VK_PRIMITIVE_TOPOLOGY_LINE_STRIP] = PIPE_PRIM_LINE_STRIP,
1057
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST] = PIPE_PRIM_TRIANGLES,
1058
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP] = PIPE_PRIM_TRIANGLE_STRIP,
1059
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN] = PIPE_PRIM_TRIANGLE_FAN,
1060
[VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY] = PIPE_PRIM_LINES_ADJACENCY,
1061
[VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY] = PIPE_PRIM_LINE_STRIP_ADJACENCY,
1062
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY] = PIPE_PRIM_TRIANGLES_ADJACENCY,
1063
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY] = PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY,
1045
static const enum mesa_prim vk_to_mesa_prim[] = {
1046
[VK_PRIMITIVE_TOPOLOGY_POINT_LIST] = MESA_PRIM_POINTS,
1047
[VK_PRIMITIVE_TOPOLOGY_LINE_LIST] = MESA_PRIM_LINES,
1048
[VK_PRIMITIVE_TOPOLOGY_LINE_STRIP] = MESA_PRIM_LINE_STRIP,
1049
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST] = MESA_PRIM_TRIANGLES,
1050
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP] = MESA_PRIM_TRIANGLE_STRIP,
1051
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN] = MESA_PRIM_TRIANGLE_FAN,
1052
[VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY] = MESA_PRIM_LINES_ADJACENCY,
1053
[VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY] = MESA_PRIM_LINE_STRIP_ADJACENCY,
1054
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY] = MESA_PRIM_TRIANGLES_ADJACENCY,
1055
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY] = MESA_PRIM_TRIANGLE_STRIP_ADJACENCY,
1066
1058
static const enum pipe_logicop vk_to_pipe_logicop[] = {
1101
1093
const VkPipelineInputAssemblyStateCreateInfo *ia_info =
1102
1094
pCreateInfo->pInputAssemblyState;
1103
uint8_t topology = vk_to_pipe_prim_type[ia_info->topology];
1095
uint8_t topology = vk_to_mesa_prim[ia_info->topology];
1105
key->is_points = (topology == PIPE_PRIM_POINTS);
1106
key->is_lines = (topology >= PIPE_PRIM_LINES &&
1107
topology <= PIPE_PRIM_LINE_STRIP);
1097
key->is_points = (topology == MESA_PRIM_POINTS);
1098
key->is_lines = (topology >= MESA_PRIM_LINES &&
1099
topology <= MESA_PRIM_LINE_STRIP);
1108
1100
key->has_gs = has_geometry_shader;
1110
1102
const VkPipelineColorBlendStateCreateInfo *cb_info =
1272
1264
const VkPipelineInputAssemblyStateCreateInfo *ia_info =
1273
1265
pCreateInfo->pInputAssemblyState;
1274
uint8_t topology = vk_to_pipe_prim_type[ia_info->topology];
1266
uint8_t topology = vk_to_mesa_prim[ia_info->topology];
1276
1268
/* FIXME: PRIM_POINTS is not enough, in gallium the full check is
1277
* PIPE_PRIM_POINTS && v3d->rasterizer->base.point_size_per_vertex */
1278
key->per_vertex_point_size = (topology == PIPE_PRIM_POINTS);
1269
* MESA_PRIM_POINTS && v3d->rasterizer->base.point_size_per_vertex */
1270
key->per_vertex_point_size = (topology == MESA_PRIM_POINTS);
1280
1272
key->is_coord = broadcom_shader_stage_is_binning(p_stage->stage);
1340
1332
const VkVertexInputAttributeDescription *desc =
1341
1333
&vi_info->pVertexAttributeDescriptions[i];
1342
1334
assert(desc->location < MAX_VERTEX_ATTRIBS);
1343
if (desc->format == VK_FORMAT_B8G8R8A8_UNORM)
1335
if (desc->format == VK_FORMAT_B8G8R8A8_UNORM ||
1336
desc->format == VK_FORMAT_A2R10G10B10_UNORM_PACK32) {
1344
1337
key->va_swap_rb_mask |= 1 << (VERT_ATTRIB_GENERIC0 + desc->location);
1648
1642
if (!qpu_insts) {
1649
1643
fprintf(stderr, "Failed to compile %s prog %d NIR to VIR\n",
1650
gl_shader_stage_name(p_stage->stage),
1644
broadcom_shader_stage_name(p_stage->stage),
1651
1645
p_stage->program_id);
1652
1646
*out_vk_result = VK_ERROR_UNKNOWN;
1791
1785
assert(nir->info.stage == broadcom_shader_stage_to_gl(p_stage->stage));
1793
/* A NIR cach hit doesn't avoid the large majority of pipeline stage
1787
/* A NIR cache hit doesn't avoid the large majority of pipeline stage
1794
1788
* creation so the cache hit is not recorded in the pipeline feedback
1934
1928
const VkPipelineInputAssemblyStateCreateInfo *ia_info =
1935
1929
pCreateInfo->pInputAssemblyState;
1936
key->topology = vk_to_pipe_prim_type[ia_info->topology];
1930
key->topology = vk_to_mesa_prim[ia_info->topology];
1938
1932
const VkPipelineColorBlendStateCreateInfo *cb_info =
1939
1933
raster_enabled ? pCreateInfo->pColorBlendState : NULL;
1998
1992
const VkVertexInputAttributeDescription *desc =
1999
1993
&vi_info->pVertexAttributeDescriptions[i];
2000
1994
assert(desc->location < MAX_VERTEX_ATTRIBS);
2001
if (desc->format == VK_FORMAT_B8G8R8A8_UNORM)
1995
if (desc->format == VK_FORMAT_B8G8R8A8_UNORM ||
1996
desc->format == VK_FORMAT_A2R10G10B10_UNORM_PACK32) {
2002
1997
key->va_swap_rb_mask |= 1 << (VERT_ATTRIB_GENERIC0 + desc->location);
2005
2001
assert(pipeline->subpass);
2133
static enum shader_prim
2129
static enum mesa_prim
2134
2130
multiview_gs_input_primitive_from_pipeline(struct v3dv_pipeline *pipeline)
2136
2132
switch (pipeline->topology) {
2137
case PIPE_PRIM_POINTS:
2138
return SHADER_PRIM_POINTS;
2139
case PIPE_PRIM_LINES:
2140
case PIPE_PRIM_LINE_STRIP:
2141
return SHADER_PRIM_LINES;
2142
case PIPE_PRIM_TRIANGLES:
2143
case PIPE_PRIM_TRIANGLE_STRIP:
2144
case PIPE_PRIM_TRIANGLE_FAN:
2145
return SHADER_PRIM_TRIANGLES;
2133
case MESA_PRIM_POINTS:
2134
return MESA_PRIM_POINTS;
2135
case MESA_PRIM_LINES:
2136
case MESA_PRIM_LINE_STRIP:
2137
return MESA_PRIM_LINES;
2138
case MESA_PRIM_TRIANGLES:
2139
case MESA_PRIM_TRIANGLE_STRIP:
2140
case MESA_PRIM_TRIANGLE_FAN:
2141
return MESA_PRIM_TRIANGLES;
2147
2143
/* Since we don't allow GS with multiview, we can only see non-adjacency
2154
static enum shader_prim
2150
static enum mesa_prim
2155
2151
multiview_gs_output_primitive_from_pipeline(struct v3dv_pipeline *pipeline)
2157
2153
switch (pipeline->topology) {
2158
case PIPE_PRIM_POINTS:
2159
return SHADER_PRIM_POINTS;
2160
case PIPE_PRIM_LINES:
2161
case PIPE_PRIM_LINE_STRIP:
2162
return SHADER_PRIM_LINE_STRIP;
2163
case PIPE_PRIM_TRIANGLES:
2164
case PIPE_PRIM_TRIANGLE_STRIP:
2165
case PIPE_PRIM_TRIANGLE_FAN:
2166
return SHADER_PRIM_TRIANGLE_STRIP;
2154
case MESA_PRIM_POINTS:
2155
return MESA_PRIM_POINTS;
2156
case MESA_PRIM_LINES:
2157
case MESA_PRIM_LINE_STRIP:
2158
return MESA_PRIM_LINE_STRIP;
2159
case MESA_PRIM_TRIANGLES:
2160
case MESA_PRIM_TRIANGLE_STRIP:
2161
case MESA_PRIM_TRIANGLE_FAN:
2162
return MESA_PRIM_TRIANGLE_STRIP;
2168
2164
/* Since we don't allow GS with multiview, we can only see non-adjacency
2910
2906
const VkPipelineInputAssemblyStateCreateInfo *ia_info =
2911
2907
pCreateInfo->pInputAssemblyState;
2912
pipeline->topology = vk_to_pipe_prim_type[ia_info->topology];
2908
pipeline->topology = vk_to_mesa_prim[ia_info->topology];
2914
2910
/* If rasterization is not enabled, various CreateInfo structs must be