radv: Support VK_EXT_inline_uniform_block.
Basically just reserve the memory in the descriptor sets. On the shader side we construct a buffer descriptor, since AFAIU VGPR indexing on 32-bit pointers in LLVM is still broken. This fully supports update after bind and variable descriptor set sizes. However, the limits are somewhat arbitrary and are mostly about finding a reasonable division of a 2 GiB max memory size over the set. v2: - rebased on top of master (Samuel) - remove the loading resources rework (Samuel) - only load UBO descriptors if it's a pointer (Samuel) - use LLVMBuildPtrToInt to avoid IR failures (Samuel) Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> (v2)
This commit is contained in:

committed by
Samuel Pitoiset

parent
2b515a8259
commit
8d2654a419
@@ -1305,13 +1305,35 @@ radv_load_resource(struct ac_shader_abi *abi, LLVMValueRef index,
|
||||
} else
|
||||
stride = LLVMConstInt(ctx->ac.i32, layout->binding[binding].size, false);
|
||||
|
||||
offset = ac_build_imad(&ctx->ac, index, stride,
|
||||
LLVMConstInt(ctx->ac.i32, base_offset, false));
|
||||
offset = LLVMConstInt(ctx->ac.i32, base_offset, false);
|
||||
|
||||
if (layout->binding[binding].type != VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT) {
|
||||
offset = ac_build_imad(&ctx->ac, index, stride, offset);
|
||||
}
|
||||
|
||||
desc_ptr = ac_build_gep0(&ctx->ac, desc_ptr, offset);
|
||||
desc_ptr = ac_cast_ptr(&ctx->ac, desc_ptr, ctx->ac.v4i32);
|
||||
LLVMSetMetadata(desc_ptr, ctx->ac.uniform_md_kind, ctx->ac.empty_md);
|
||||
|
||||
if (layout->binding[binding].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT) {
|
||||
uint32_t desc_type = S_008F0C_DST_SEL_X(V_008F0C_SQ_SEL_X) |
|
||||
S_008F0C_DST_SEL_Y(V_008F0C_SQ_SEL_Y) |
|
||||
S_008F0C_DST_SEL_Z(V_008F0C_SQ_SEL_Z) |
|
||||
S_008F0C_DST_SEL_W(V_008F0C_SQ_SEL_W) |
|
||||
S_008F0C_NUM_FORMAT(V_008F0C_BUF_NUM_FORMAT_FLOAT) |
|
||||
S_008F0C_DATA_FORMAT(V_008F0C_BUF_DATA_FORMAT_32);
|
||||
|
||||
LLVMValueRef desc_components[4] = {
|
||||
LLVMBuildPtrToInt(ctx->ac.builder, desc_ptr, ctx->ac.intptr, ""),
|
||||
LLVMConstInt(ctx->ac.i32, S_008F04_BASE_ADDRESS_HI(ctx->options->address32_hi), false),
|
||||
/* High limit to support variable sizes. */
|
||||
LLVMConstInt(ctx->ac.i32, 0xffffffff, false),
|
||||
LLVMConstInt(ctx->ac.i32, desc_type, false),
|
||||
};
|
||||
|
||||
return ac_build_gather_values(&ctx->ac, desc_components, 4);
|
||||
}
|
||||
|
||||
return desc_ptr;
|
||||
}
|
||||
|
||||
@@ -1910,6 +1932,11 @@ static LLVMValueRef radv_load_ubo(struct ac_shader_abi *abi, LLVMValueRef buffer
|
||||
struct radv_shader_context *ctx = radv_shader_context_from_abi(abi);
|
||||
LLVMValueRef result;
|
||||
|
||||
if (LLVMGetTypeKind(LLVMTypeOf(buffer_ptr)) != LLVMPointerTypeKind) {
|
||||
/* Do not load the descriptor for inlined uniform blocks. */
|
||||
return buffer_ptr;
|
||||
}
|
||||
|
||||
LLVMSetMetadata(buffer_ptr, ctx->ac.uniform_md_kind, ctx->ac.empty_md);
|
||||
|
||||
result = LLVMBuildLoad(ctx->ac.builder, buffer_ptr, "");
|
||||
|
Reference in New Issue
Block a user