Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.

Commit

Permalink
spirv: Add support for using derefs for UBO/SSBO access
Browse files Browse the repository at this point in the history
For now, it's hidden behind a cap.  Hopefully, we can eventually drop
that along with all the manual offset code in spirv_to_nir.

Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com>
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Tested-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
  • Loading branch information
gfxstrand committed Jan 8, 2019
1 parent 3a7c566 commit 63b9aa2
Show file tree
Hide file tree
Showing 9 changed files with 273 additions and 68 deletions.
1 change: 1 addition & 0 deletions src/amd/vulkan/radv_shader.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
}
}
const struct spirv_to_nir_options spirv_options = {
.lower_ubo_ssbo_access_to_offsets = true,
.caps = {
.device_group = true,
.draw_parameters = true,
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/nir/nir_intrinsics.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,8 @@ def image(name, src_comp=[], **kwargs):
flags=[CAN_ELIMINATE, CAN_REORDER])
intrinsic("vulkan_resource_reindex", src_comp=[1, 1], dest_comp=1,
indices=[DESC_TYPE], flags=[CAN_ELIMINATE, CAN_REORDER])
intrinsic("load_vulkan_descriptor", src_comp=[1], dest_comp=0,
indices=[DESC_TYPE], flags=[CAN_ELIMINATE, CAN_REORDER])

# variable atomic intrinsics
#
Expand Down
3 changes: 3 additions & 0 deletions src/compiler/spirv/nir_spirv.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ struct spirv_to_nir_options {
*/
bool lower_workgroup_access_to_offsets;

/* Whether or not to lower all UBO/SSBO access to offsets up-front. */
bool lower_ubo_ssbo_access_to_offsets;

struct spirv_supported_capabilities caps;

/* Storage types for various kinds of pointers. */
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/spirv/spirv_to_nir.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ struct member_decoration_ctx {
* Returns true if the given type contains a struct decorated Block or
* BufferBlock
*/
static bool
bool
vtn_type_contains_block(struct vtn_builder *b, struct vtn_type *type)
{
switch (type->base_type) {
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/spirv/vtn_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ struct vtn_type {
};
};

bool vtn_type_contains_block(struct vtn_builder *b, struct vtn_type *type);

bool vtn_types_compatible(struct vtn_builder *b,
struct vtn_type *t1, struct vtn_type *t2);

Expand Down
Loading

0 comments on commit 63b9aa2

Please sign in to comment.