diff options
Diffstat (limited to 'src/amd')
-rw-r--r-- | src/amd/vulkan/radv_descriptor_set.c | 5 | ||||
-rw-r--r-- | src/amd/vulkan/radv_descriptor_set.h | 2 | ||||
-rw-r--r-- | src/amd/vulkan/radv_nir_to_llvm.c | 26 |
3 files changed, 26 insertions, 7 deletions
diff --git a/src/amd/vulkan/radv_descriptor_set.c b/src/amd/vulkan/radv_descriptor_set.c index 4e9c73c94d0..bd00f68a3cb 100644 --- a/src/amd/vulkan/radv_descriptor_set.c +++ b/src/amd/vulkan/radv_descriptor_set.c @@ -200,7 +200,7 @@ VkResult radv_CreateDescriptorSetLayout( break; case VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER: /* main descriptor + fmask descriptor + sampler */ - set_layout->binding[b].size = 32 + 32 * max_sampled_image_descriptors; + set_layout->binding[b].size = 96; binding_buffer_count = 1; alignment = 32; break; @@ -247,7 +247,8 @@ VkResult radv_CreateDescriptorSetLayout( /* Don't reserve space for the samplers if they're not accessed. */ if (set_layout->binding[b].immutable_samplers_equal) { - if (binding->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) + if (binding->descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER && + max_sampled_image_descriptors <= 2) set_layout->binding[b].size -= 32; else if (binding->descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) set_layout->binding[b].size -= 16; diff --git a/src/amd/vulkan/radv_descriptor_set.h b/src/amd/vulkan/radv_descriptor_set.h index 5fd19d94482..89be6e69068 100644 --- a/src/amd/vulkan/radv_descriptor_set.h +++ b/src/amd/vulkan/radv_descriptor_set.h @@ -104,7 +104,7 @@ radv_immutable_samplers(const struct radv_descriptor_set_layout *set, static inline unsigned radv_combined_image_descriptor_sampler_offset(const struct radv_descriptor_set_binding_layout *binding) { - return binding->size - ((!binding->immutable_samplers_equal) ? 32 : 0); + return binding->size - ((!binding->immutable_samplers_equal) ? 16 : 0); } static inline const struct radv_sampler_ycbcr_conversion * diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index d83f0bd547f..5a34a85d7b4 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -2019,16 +2019,34 @@ static LLVMValueRef radv_get_sampler_desc(struct ac_shader_abi *abi, assert(stride % type_size == 0); - if (!index) - index = ctx->ac.i32_0; + LLVMValueRef adjusted_index = index; + if (!adjusted_index) + adjusted_index = ctx->ac.i32_0; - index = LLVMBuildMul(builder, index, LLVMConstInt(ctx->ac.i32, stride / type_size, 0), ""); + adjusted_index = LLVMBuildMul(builder, adjusted_index, LLVMConstInt(ctx->ac.i32, stride / type_size, 0), ""); list = ac_build_gep0(&ctx->ac, list, LLVMConstInt(ctx->ac.i32, offset, 0)); list = LLVMBuildPointerCast(builder, list, ac_array_in_const32_addr_space(type), ""); - return ac_build_load_to_sgpr(&ctx->ac, list, index); + LLVMValueRef descriptor = ac_build_load_to_sgpr(&ctx->ac, list, adjusted_index); + + /* 3 plane formats always have same size and format for plane 1 & 2, so + * use the tail from plane 1 so that we can store only the first 16 bytes + * of the last plane. */ + if (desc_type == AC_DESC_PLANE_2) { + LLVMValueRef descriptor2 = radv_get_sampler_desc(abi, descriptor_set, base_index, constant_index, index, AC_DESC_PLANE_1,image, write, bindless); + + LLVMValueRef components[8]; + for (unsigned i = 0; i < 4; ++i) + components[i] = ac_llvm_extract_elem(&ctx->ac, descriptor, i); + + for (unsigned i = 4; i < 8; ++i) + components[i] = ac_llvm_extract_elem(&ctx->ac, descriptor2, i); + descriptor = ac_build_gather_values(&ctx->ac, components, 8); + } + + return descriptor; } /* For 2_10_10_10 formats the alpha is handled as unsigned by pre-vega HW. |