mesa编译器lower ubo出现问题

概述

hlsl源代码

cbuffer cbPerObject : register(b0)
{
   
    float4x4 gWorld;
};


struct VertexIn
{
   
    float3 PosL : POSITION;
    float4 Color : COLOR;
};

struct VertexOut
{
   
    float4 PosH : SV_POSITION;
    float4 Color : COLOR;
};

VertexOut VSMain(VertexIn vin)
{
   
    VertexOut vout;
	
	// Transform to homogeneous clip space.
    vout.PosH = mul(float4(vin.PosL, 1.0f), gWorld);
	
	// Just pass vertex color into the pixel shader.
    vout.Color = vin.Color;
    
    return vout;
}

spirv

省略掉dxil转spirv的过程。生成的spirv如下所示:

; SPIR-V
; Version: 1.3
; Generator: Unknown(30017); 21022
; Bound: 93
; Schema: 0
OpCapability Shader
%66 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Vertex %3 "main" %15 %17 %19 %20
OpName %3 "main"
OpName %10 ""
OpName %15 "POSITION"
OpName %17 "COLOR"
OpName %19 "SV_Position"
OpName %20 "COLOR"
OpDecorate %9 ArrayStride 16
OpMemberDecorate %10 0 Offset 0
OpDecorate %10 Block
OpDecorate %12 DescriptorSet 0
OpDecorate %12 Binding 0
OpDecorate %15 Location 0
OpDecorate %17 Location 1
OpDecorate %19 BuiltIn Position
OpDecorate %20 Location 1
%1 = OpTypeVoid
%2 = OpTypeFunction %1
%5 = OpTypeInt 32 0
%6 = OpConstant %5 4
%7 = OpTypeFloat 32
%8 = OpTypeVector %7 4
%9 = OpTypeArray %8 %6
%10 = OpTypeStruct %9
%11 = OpTypePointer Uniform %10
%12 = OpVariable %11 Uniform
%13 = OpTypeVector %7 3
%14 = OpTypePointer Input %13
%15 = OpVariable %14 Input
%16 = OpTypePointer Input %8
%17 = OpVariable %16 Input
%18 = OpTypePointer Output %8
%19 = OpVariable %18 Output
%20 = OpVariable %18 Output
%21 = OpTypePointer Input %7
%23 = OpConstant %5 0
%26 = OpConstant %5 1
%29 = OpConstant %5 2
%32 = OpConstant %5 3
%40 = OpTypePointer Uniform %8
%82 = OpTypePointer Output %7
%3 = OpFunction %1 None %2
%4 = OpLabel
OpBranch %91
%91 = OpLabel
%22 = OpAccessChain %21 %17 %23
%24 = OpLoad %7 %22
%25 = OpAccessChain %21 %17 %26
%27 = OpLoad %7 %25
%28 = OpAccessChain %21 %17 %29
%30 = OpLoad %7 %28
%31 = OpAccessChain %21 %17 %32
%33 = OpLoad %7 %31
%34 = OpAccessChain %21 %15 %23
%35 = OpLoad %7 %34
%36 = OpAccessChain %21 %15 %26
%37 = OpLoad %7 %36
%38 = OpAccessChain %21 %15 %29
%39 = OpLoad %7 %38
%41 = OpAccessChain %40 %12 %23 %23
%42 = OpLoad %8 %41
%43 = OpCompositeExtract %7 %42 0
%44 = OpCompositeExtract %7 %42 1
%45 = OpCompositeExtract %7 %42 2
%46 = OpCompositeExtract %7 %42 3
%47 = OpAccessChain %40 %12 %23 %26
%48 = OpLoad %8 %47
%49 = OpCompositeExtract %7 %48 0
%50 = OpCompositeExtract %7 %48 1
%51 = OpCompositeExtract %7 %48 2
%52 = OpCompositeExtract %7 %48 3
%53 = OpAccessChain %40 %12 %23 %29
%54 = OpLoad %8 %53
%55 = OpCompositeExtract %7 %54 0
%56 = OpCompositeExtract %7 %54 1
%57 = OpCompositeExtract %7 %54 2
%58 = OpCompositeExtract %7 %54 3
%59 = OpAccessChain %40 %12 %23 %32
%60 = OpLoad %8 %59
%61 = OpCompositeExtract %7 %60 0
%62 = OpCompositeExtract %7 %60 1
%63 = OpCompositeExtract %7 %60 2
%64 = OpCompositeExtract %7 %60 3
%65 = OpFMul %7 %43 %35
%67 = OpExtInst %7 %66 Fma %37 %44 %65
%68 = OpExtInst %7 %66 Fma %39 %45 %67
%69 = OpFAdd %7 %68 %46
%70 = OpFMul %7 %49 %35
%71 = OpExtInst %7 %66 Fma %37 %50 %70
%72 = OpExtInst %7 %66 Fma %39 %51 %71
%73 = OpFAdd %7 %72 %52
%74 = OpFMul %7 %55 %35
%75 = OpExtInst %7 %66 Fma %37 %56 %74
%76 = OpExtInst %7 %66 Fma %39 %57 %75
%77 = OpFAdd %7 %76 %58
%78 = OpFMul %7 %61 %35
%79 = OpExtInst %7 %66 Fma %37 %62 %78
%80 = OpExtInst %7 %66 Fma %39 %63 %79
%81 = OpFAdd %7 %80 %64
%83 = OpAccessChain %82 %19 %23
OpStore %83 %69
%84 = OpAccessChain %82 %19 %26
OpStore %84 %73
%85 = OpAccessChain %82 %19 %29
OpStore %85 %77
%86 = OpAccessChain %82 %19 %32
OpStore %86 %81
%87 = OpAccessChain %82 %20 %23
OpStore %87 %24
%88 = OpAccessChain %82 %20 %26
OpStore %88 %27
%89 = OpAccessChain %82 %20 %29
OpStore %89 %30
%90 = OpAccessChain %82 %20 %32
OpStore %90 %33
OpReturn
OpFunctionEnd

nir

在spirv转nir的函数中,可以选择运行的环境,有三个

enum nir_spirv_execution_environment {
   
   NIR_SPIRV_VULKAN = 0,
   NIR_SPIRV_OPENCL,
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值