summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJonathan Marek <[email protected]>2019-12-12 17:05:22 -0500
committerJonathan Marek <[email protected]>2019-12-12 20:33:17 -0500
commit828f8f5531ff06b44bf74595b163d2c8189cda09 (patch)
tree2ec5cacb1f22d9bc6d7d48412fa9b6995f9c5a46 /src
parent3b4b5f549f68fd73097fc565960f8889c4bdd3c5 (diff)
turnip: implement subpass input attachments
Signed-off-by: Jonathan Marek <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/freedreno/vulkan/tu_cmd_buffer.c38
-rw-r--r--src/freedreno/vulkan/tu_private.h1
-rw-r--r--src/freedreno/vulkan/tu_shader.c16
3 files changed, 42 insertions, 13 deletions
diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c
index 26d460f4143..e949bea22e3 100644
--- a/src/freedreno/vulkan/tu_cmd_buffer.c
+++ b/src/freedreno/vulkan/tu_cmd_buffer.c
@@ -2520,9 +2520,12 @@ sampler_ptr(struct tu_descriptor_state *descriptors_state,
}
}
-static uint32_t*
-texture_ptr(struct tu_descriptor_state *descriptors_state,
- const struct tu_descriptor_map *map, unsigned i)
+static void
+write_tex_const(struct tu_cmd_buffer *cmd,
+ uint32_t *dst,
+ struct tu_descriptor_state *descriptors_state,
+ const struct tu_descriptor_map *map,
+ unsigned i)
{
assert(descriptors_state->valid & (1 << map->set[i]));
@@ -2535,14 +2538,33 @@ texture_ptr(struct tu_descriptor_state *descriptors_state,
switch (layout->type) {
case VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER:
- return &set->mapped_ptr[layout->offset / 4];
case VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
- return &set->mapped_ptr[layout->offset / 4];
+ case VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT:
+ memcpy(dst, &set->mapped_ptr[layout->offset / 4], A6XX_TEX_CONST_DWORDS*4);
+ break;
default:
unreachable("unimplemented descriptor type");
break;
}
+
+ if (layout->type == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) {
+ const struct tu_tiling_config *tiling = &cmd->state.tiling_config;
+ uint32_t a = cmd->state.subpass->input_attachments[map->value[i]].attachment;
+
+ assert(cmd->state.pass->attachments[a].needs_gmem);
+ dst[0] &= ~(A6XX_TEX_CONST_0_SWAP__MASK | A6XX_TEX_CONST_0_TILE_MODE__MASK);
+ dst[0] |= A6XX_TEX_CONST_0_TILE_MODE(TILE6_2);
+ dst[2] &= ~(A6XX_TEX_CONST_2_TYPE__MASK | A6XX_TEX_CONST_2_PITCH__MASK);
+ dst[2] |=
+ A6XX_TEX_CONST_2_TYPE(A6XX_TEX_2D) |
+ A6XX_TEX_CONST_2_PITCH(tiling->tile0.extent.width * tiling->buffer_cpp[a]);
+ dst[3] = 0;
+ dst[4] = 0x100000 + tiling->gmem_offsets[a];
+ dst[5] = A6XX_TEX_CONST_5_DEPTH(1);
+ for (unsigned i = 6; i < A6XX_TEX_CONST_DWORDS; i++)
+ dst[i] = 0;
+ }
}
static uint64_t
@@ -2737,9 +2759,9 @@ tu6_emit_textures(struct tu_cmd_buffer *cmd,
return result;
for (unsigned i = 0; i < link->texture_map.num; i++) {
- memcpy(&tex_const.map[A6XX_TEX_CONST_DWORDS*i],
- texture_ptr(descriptors_state, &link->texture_map, i),
- A6XX_TEX_CONST_DWORDS*4);
+ write_tex_const(cmd,
+ &tex_const.map[A6XX_TEX_CONST_DWORDS*i],
+ descriptors_state, &link->texture_map, i);
}
/* allocate and fill sampler state */
diff --git a/src/freedreno/vulkan/tu_private.h b/src/freedreno/vulkan/tu_private.h
index e3cc32fdf7c..c120ef1349d 100644
--- a/src/freedreno/vulkan/tu_private.h
+++ b/src/freedreno/vulkan/tu_private.h
@@ -1054,6 +1054,7 @@ struct tu_descriptor_map
unsigned num;
int set[64];
int binding[64];
+ int value[64];
};
struct tu_shader
diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c
index a220f8ce4df..9a904e61d07 100644
--- a/src/freedreno/vulkan/tu_shader.c
+++ b/src/freedreno/vulkan/tu_shader.c
@@ -109,7 +109,7 @@ tu_sort_variables_by_location(struct exec_list *variables)
}
static unsigned
-map_add(struct tu_descriptor_map *map, int set, int binding)
+map_add(struct tu_descriptor_map *map, int set, int binding, int value)
{
unsigned index;
for (index = 0; index < map->num; index++) {
@@ -121,6 +121,7 @@ map_add(struct tu_descriptor_map *map, int set, int binding)
map->set[index] = set;
map->binding[index] = binding;
+ map->value[index] = value;
map->num = MAX2(map->num, index + 1);
return index;
}
@@ -189,12 +190,14 @@ lower_tex_src_to_offset(nir_builder *b, nir_tex_instr *instr, unsigned src_idx,
if (is_sampler) {
instr->sampler_index = map_add(&shader->sampler_map,
deref->var->data.descriptor_set,
- deref->var->data.binding);
+ deref->var->data.binding,
+ 0);
instr->sampler_index += base_index;
} else {
instr->texture_index = map_add(&shader->texture_map,
deref->var->data.descriptor_set,
- deref->var->data.binding);
+ deref->var->data.binding,
+ deref->var->data.index);
instr->texture_index += base_index;
instr->texture_array_size = array_elements;
}
@@ -269,11 +272,11 @@ lower_intrinsic(nir_builder *b, nir_intrinsic_instr *instr,
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
case VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC:
/* skip index 0 which is used for push constants */
- index = map_add(&shader->ubo_map, set, binding) + 1;
+ index = map_add(&shader->ubo_map, set, binding, 0) + 1;
break;
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER:
case VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC:
- index = map_add(&shader->ssbo_map, set, binding);
+ index = map_add(&shader->ssbo_map, set, binding, 0);
break;
default:
tu_finishme("unsupported desc_type for vulkan_resource_index");
@@ -420,6 +423,9 @@ tu_shader_create(struct tu_device *dev,
NIR_PASS_V(nir, nir_lower_system_values);
NIR_PASS_V(nir, nir_lower_frexp);
+ if (stage == MESA_SHADER_FRAGMENT)
+ NIR_PASS_V(nir, nir_lower_input_attachments, true);
+
NIR_PASS_V(nir, tu_lower_io, shader);
NIR_PASS_V(nir, nir_lower_io, nir_var_all, ir3_glsl_type_size, 0);