Closed ytgui closed 5 years ago
#version 450
precision highp float;
layout (set = 0, binding = 0) uniform UBO
{
vec4 inColor;
} ubo;
layout (location = 0) out vec4 fragColor;
void main()
{
fragColor = vec4(ubo.inColor);
}
define void @__start() !current_variant_flags !15 !target_variants_flags !16 {
entry:
; ld ubo
%_1_ = call i32 @llvm.bifroxt.get.buffer.of(metadata !3, i32 1)
%_3_ = call i32 @llvm.bifroxt.default.uniform.buffer(metadata !3)
%_3_1 = call i32 @llvm.bifroxt.get.uniform.buffer.offset.i32(metadata !3, i32 16)
%_3_2 = add i32 %_3_1, 0
%_3_3 = call nsrnd <4 x float> @llvm.bifroxt.ld.uniform.dtsel.v4f32(i32 %_3_, i32 %_3_2, i32 -1)
; ignore fragColor out
ret void
}
Push constants is a way to quickly provide a small amount of uniform data to shaders. It should be much quicker than UBOs but a huge limitation is the size of data - spec requires 128 bytes to be available for a push constant range. Hardware vendors may support more, but compared to other means it is still very little (for example 256 bytes).
#version 450
precision highp float; layout (push_constant) uniform PushConstant { vec4 inColor; } pc; layout (location = 0) out vec4 fragColor;
void main() { fragColor = vec4(pc.inColor); }
```LLVM
define void @__start() !current_variant_flags !15 !target_variants_flags !16 {
entry:
; mali do the same to UBO
%_1_ = call i32 @llvm.bifroxt.get.buffer.of(metadata !3, i32 1)
%_3_ = call i32 @llvm.bifroxt.default.uniform.buffer(metadata !3)
%_3_1 = call i32 @llvm.bifroxt.get.uniform.buffer.offset.i32(metadata !3, i32 16)
%_3_2 = add i32 %_3_1, 0
%_3_3 = call nsrnd <4 x float> @llvm.bifroxt.ld.uniform.dtsel.v4f32(i32 %_3_, i32 %_3_2, i32 -1)
ret void
}
#version 450
precision highp float;
layout (binding = 0, r16f) uniform highp image2D srcImg;
layout (binding = 1, r16f) uniform highp image2D dstImg;
void main()
{
ivec2 index = ivec2(gl_GlobalInvocationID.x,
gl_GlobalInvocationID.y);
vec4 value = imageLoad(srcImg, index);
imageStore(dstImg, index, value);
}
define void @__start() !current_variant_flags !15 !target_variants_flags !16 {
entry:
; ignore useless ir
%1 = call i32 @llvm.bifroxt.ld.img.v2i32(...)
call i32 @llvm.bifroxt.st.img.v2i32(%1, ...)
ret void
}
Basic VS I/O
Basic FS I/O