Add support for top-level uniforms in SPIR-V.

Previously, a uniform not wrapped in an interface block would report a
SPIR-V error:

"Variables identified with the Uniform storage class are
used to access transparent buffer backed resources. Such variables must
be typed as OpTypeStruct, or an array of this type..."

Now, the SPIR-V code generator automatically detects such global
variables and synthesizes a struct named _UniformBuffer to hold them.
When these variables are accessed, an OpAccessChain instruction is added
to grab the variable out of the struct.

Change-Id: I5e852d4de01b866c291506cc8cf6eb547f097d66
Bug: skia:11225
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/360776
Commit-Queue: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
This commit is contained in:
John Stiles 2021-01-28 15:11:39 -05:00
parent 96a97497b3
commit acba30420c
12 changed files with 549 additions and 453 deletions

View File

@ -1742,7 +1742,7 @@ std::vector<SpvId> SPIRVCodeGenerator::getAccessChain(const Expression& expr, Ou
case Expression::Kind::kFieldAccess: {
const FieldAccess& fieldExpr = expr.as<FieldAccess>();
chain = this->getAccessChain(*fieldExpr.base(), out);
IntLiteral index(fContext, -1, fieldExpr.fieldIndex());
IntLiteral index(fContext, /*offset=*/-1, fieldExpr.fieldIndex());
chain.push_back(this->writeIntLiteral(index));
break;
}
@ -1867,14 +1867,30 @@ private:
const SPIRVCodeGenerator::Precision fPrecision;
};
int SPIRVCodeGenerator::findUniformFieldIndex(const Variable& var) const {
auto iter = fTopLevelUniformMap.find(&var);
return (iter != fTopLevelUniformMap.end()) ? iter->second : -1;
}
std::unique_ptr<SPIRVCodeGenerator::LValue> SPIRVCodeGenerator::getLValue(const Expression& expr,
OutputStream& out) {
const Type& type = expr.type();
Precision precision = type.highPrecision() ? Precision::kHigh : Precision::kLow;
switch (expr.kind()) {
case Expression::Kind::kVariableReference: {
SpvId typeId;
const Variable& var = *expr.as<VariableReference>().variable();
int uniformIdx = this->findUniformFieldIndex(var);
if (uniformIdx >= 0) {
IntLiteral uniformIdxLiteral{fContext, /*offset=*/-1, uniformIdx};
SpvId memberId = this->nextId();
SpvId typeId = this->getPointerType(type, SpvStorageClassUniform);
SpvId uniformIdxId = this->writeIntLiteral(uniformIdxLiteral);
this->writeInstruction(SpvOpAccessChain, typeId, memberId, fUniformBufferId,
uniformIdxId, out);
return std::make_unique<PointerLValue>(*this, memberId, this->getType(type),
precision);
}
SpvId typeId;
if (var.modifiers().fLayout.fBuiltin == SK_IN_BUILTIN) {
typeId = this->getType(*Type::MakeArrayType("sk_in", var.type().componentType(),
fSkInCount));
@ -1955,13 +1971,21 @@ std::unique_ptr<SPIRVCodeGenerator::LValue> SPIRVCodeGenerator::getLValue(const
}
SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, OutputStream& out) {
// Is this variable is actually a uniform at global scope?
const Variable* variable = ref.variable();
if (this->findUniformFieldIndex(*variable) >= 0) {
// SPIR-V doesn't allow uniforms at global scope, so we've stashed them in an interface
// block. We need to fetch it from there. getLValue knows how to do this.
return this->getLValue(ref, out)->load(out);
}
SpvId result = this->nextId();
auto entry = fVariableMap.find(ref.variable());
auto entry = fVariableMap.find(variable);
SkASSERT(entry != fVariableMap.end());
SpvId var = entry->second;
this->writeInstruction(SpvOpLoad, this->getType(ref.variable()->type()), result, var, out);
this->writePrecisionModifier(ref.variable()->type(), result);
if (ref.variable()->modifiers().fLayout.fBuiltin == SK_FRAGCOORD_BUILTIN &&
this->writeInstruction(SpvOpLoad, this->getType(variable->type()), result, var, out);
this->writePrecisionModifier(variable->type(), result);
if (variable->modifiers().fLayout.fBuiltin == SK_FRAGCOORD_BUILTIN &&
fProgram.fSettings.fFlipY) {
// The x component never changes, so just grab it
SpvId xId = this->nextId();
@ -1983,11 +2007,14 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, O
fErrors.error(ref.fOffset, "RTHeightOffset is negative");
}
fields.emplace_back(
Modifiers(Layout(0, -1, fProgram.fSettings.fRTHeightOffset, -1, -1, -1, -1,
-1, Layout::Format::kUnspecified,
Layout::kUnspecified_Primitive, 1, -1, "", "",
Modifiers(Layout(/*flags=*/0, /*location=*/-1,
fProgram.fSettings.fRTHeightOffset,
/*binding=*/-1, /*index=*/-1, /*set=*/-1, /*builtin=*/-1,
/*inputAttachmentIndex=*/-1, Layout::Format::kUnspecified,
Layout::kUnspecified_Primitive, /*maxVertices=*/1,
/*invocations=*/-1, /*marker=*/"", /*when=*/"",
Layout::kNo_Key, Layout::CType::kDefault),
0),
/*flags=*/0),
SKSL_RTHEIGHT_NAME, fContext.fTypes.fFloat.get());
StringFragment name("sksl_synthetic_uniforms");
std::unique_ptr<Type> intfStruct = Type::MakeStructType(/*offset=*/-1, name,
@ -2000,10 +2027,13 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, O
if (set == -1) {
fErrors.error(ref.fOffset, "layout(set=...) is required in SPIR-V");
}
Layout layout(0, -1, -1, binding, -1, set, -1, -1, Layout::Format::kUnspecified,
Layout::kUnspecified_Primitive, -1, -1, "", "", Layout::kNo_Key,
Layout::CType::kDefault);
Modifiers modifiers(layout, Modifiers::kUniform_Flag);
Modifiers modifiers(
Layout(/*flags=*/0, /*location=*/-1, /*offset=*/-1, binding, /*index=*/-1,
set, /*builtin=*/-1, /*inputAttachmentIndex=*/-1,
Layout::Format::kUnspecified, Layout::kUnspecified_Primitive,
/*maxVertices=*/-1, /*invocations=*/-1, /*marker=*/"", /*when=*/"",
Layout::kNo_Key, Layout::CType::kDefault),
Modifiers::kUniform_Flag);
const Variable* intfVar = fSynthetics.takeOwnershipOfSymbol(
std::make_unique<Variable>(/*offset=*/-1,
fProgram.fModifiers->addToPool(modifiers),
@ -2064,7 +2094,7 @@ SpvId SPIRVCodeGenerator::writeVariableReference(const VariableReference& ref, O
return adjusted;
}
if (ref.variable()->modifiers().fLayout.fBuiltin == SK_CLOCKWISE_BUILTIN &&
if (variable->modifiers().fLayout.fBuiltin == SK_CLOCKWISE_BUILTIN &&
!fProgram.fSettings.fFlipY) {
// FrontFacing in Vulkan is defined in terms of a top-down render target. In skia, we use
// the default convention of "counter-clockwise face is front".
@ -2879,8 +2909,7 @@ static bool is_dead(const Variable& var, const ProgramUsage* usage) {
return var.modifiers().fLayout.fBuiltin == SK_SAMPLEMASK_BUILTIN;
}
void SPIRVCodeGenerator::writeGlobalVar(Program::Kind kind, const VarDeclaration& varDecl,
OutputStream& out) {
void SPIRVCodeGenerator::writeGlobalVar(Program::Kind kind, const VarDeclaration& varDecl) {
const Variable& var = varDecl.var();
// These haven't been implemented in our SPIR-V generator yet and we only currently use them
// in the OpenGL backend.
@ -2903,11 +2932,15 @@ void SPIRVCodeGenerator::writeGlobalVar(Program::Kind kind, const VarDeclaration
if (is_dead(var, fProgram.fUsage.get())) {
return;
}
const Type& type = var.type();
SpvStorageClass_ storageClass = get_storage_class(var, SpvStorageClassPrivate);
if (storageClass == SpvStorageClassUniform) {
// Top-level uniforms are emitted in writeUniformBuffer.
fTopLevelUniforms.push_back(&varDecl);
return;
}
const Type& type = var.type();
Layout layout = var.modifiers().fLayout;
if (layout.fSet < 0 && (storageClass == SpvStorageClassUniform ||
storageClass == SpvStorageClassUniformConstant)) {
if (layout.fSet < 0 && storageClass == SpvStorageClassUniformConstant) {
layout.fSet = fProgram.fSettings.fDefaultUniformSet;
}
SpvId id = this->nextId();
@ -3224,14 +3257,18 @@ void SPIRVCodeGenerator::writeGeometryShaderExecutionMode(SpvId entryPoint, Outp
invocations, out);
}
// Given any function, returns the top-level symbol table (OUTSIDE of the function's scope).
static std::shared_ptr<SymbolTable> get_top_level_symbol_table(const FunctionDeclaration& anyFunc) {
return anyFunc.definition()->body()->as<Block>().symbolTable()->fParent;
}
SPIRVCodeGenerator::EntrypointAdapter SPIRVCodeGenerator::writeEntrypointAdapter(
const FunctionDeclaration& main) {
// Our goal is to synthesize a tiny helper function which looks like this:
// void _entrypoint() { sk_FragColor = main(); }
// Fish a symbol table out of main().
std::shared_ptr<SymbolTable> symbolTable =
main.definition()->body()->as<Block>().symbolTable()->fParent;
std::shared_ptr<SymbolTable> symbolTable = get_top_level_symbol_table(main);
// Get `sk_FragColor` as a writable reference.
const Symbol* skFragColorSymbol = (*symbolTable)["sk_FragColor"];
@ -3282,6 +3319,45 @@ SPIRVCodeGenerator::EntrypointAdapter SPIRVCodeGenerator::writeEntrypointAdapter
return adapter;
}
SPIRVCodeGenerator::UniformBuffer SPIRVCodeGenerator::writeUniformBuffer(
std::shared_ptr<SymbolTable> topLevelSymbolTable) {
SkASSERT(!fTopLevelUniforms.empty());
static constexpr char kUniformBufferName[] = "_UniformBuffer";
SPIRVCodeGenerator::UniformBuffer uniformBuffer;
// Convert the list of top-level uniforms into a matching struct named _UniformBuffer, and build
// a lookup table of variables to UniformBuffer field indices.
std::vector<Type::Field> fields;
fields.reserve(fTopLevelUniforms.size());
fTopLevelUniformMap.reserve(fTopLevelUniforms.size());
for (const VarDeclaration* topLevelUniform : fTopLevelUniforms) {
const Variable* var = &topLevelUniform->var();
fTopLevelUniformMap[var] = (int)fields.size();
fields.emplace_back(var->modifiers(), var->name(), &var->type());
}
uniformBuffer.fStruct = Type::MakeStructType(/*offset=*/-1, kUniformBufferName,
std::move(fields));
// Create a global variable to contain this struct.
uniformBuffer.fLayout.fBinding = fProgram.fSettings.fDefaultUniformBinding;
uniformBuffer.fLayout.fSet = fProgram.fSettings.fDefaultUniformSet;
uniformBuffer.fModifiers = Modifiers{uniformBuffer.fLayout, Modifiers::kUniform_Flag};
uniformBuffer.fInnerVariable = std::make_unique<Variable>(
/*offset=*/-1, &uniformBuffer.fModifiers, kUniformBufferName,
uniformBuffer.fStruct.get(), /*builtin=*/false, Variable::Storage::kGlobal);
// Create an interface block object for this global variable.
uniformBuffer.fInterfaceBlock = std::make_unique<InterfaceBlock>(
/*offset=*/-1, uniformBuffer.fInnerVariable.get(), kUniformBufferName,
kUniformBufferName, /*arraySize=*/0, topLevelSymbolTable);
// Generate an interface block and hold onto its ID.
fUniformBufferId = this->writeInterfaceBlock(*uniformBuffer.fInterfaceBlock);
return uniformBuffer;
}
void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream& out) {
fGLSLExtendedInstructions = this->nextId();
StringStream body;
@ -3322,10 +3398,14 @@ void SPIRVCodeGenerator::writeInstructions(const Program& program, OutputStream&
for (const ProgramElement* e : program.elements()) {
if (e->is<GlobalVarDeclaration>()) {
this->writeGlobalVar(program.fKind,
e->as<GlobalVarDeclaration>().declaration()->as<VarDeclaration>(),
body);
e->as<GlobalVarDeclaration>().declaration()->as<VarDeclaration>());
}
}
// Emit top-level uniforms into a dedicated uniform buffer.
UniformBuffer uniformBuffer;
if (!fTopLevelUniforms.empty()) {
uniformBuffer = this->writeUniformBuffer(get_top_level_symbol_table(*main));
}
// If main() returns a half4, synthesize a tiny entrypoint function which invokes the real
// main() and stores the result into sk_FragColor.
EntrypointAdapter adapter;

View File

@ -195,12 +195,14 @@ private:
SpvId writeFunction(const FunctionDefinition& f, OutputStream& out);
void writeGlobalVar(Program::Kind kind, const VarDeclaration& v, OutputStream& out);
void writeGlobalVar(Program::Kind kind, const VarDeclaration& v);
void writeVarDeclaration(const VarDeclaration& var, OutputStream& out);
SpvId writeVariableReference(const VariableReference& ref, OutputStream& out);
int findUniformFieldIndex(const Variable& var) const;
std::unique_ptr<LValue> getLValue(const Expression& value, OutputStream& out);
SpvId writeExpression(const Expression& expr, OutputStream& out);
@ -394,6 +396,16 @@ private:
EntrypointAdapter writeEntrypointAdapter(const FunctionDeclaration& main);
struct UniformBuffer {
std::unique_ptr<InterfaceBlock> fInterfaceBlock;
std::unique_ptr<Variable> fInnerVariable;
std::unique_ptr<Type> fStruct;
Layout fLayout;
Modifiers fModifiers;
};
UniformBuffer writeUniformBuffer(std::shared_ptr<SymbolTable> topLevelSymbolTable);
const Context& fContext;
const MemoryLayout fDefaultLayout;
@ -431,6 +443,11 @@ private:
// holds variables synthesized during output, for lifetime purposes
SymbolTable fSynthetics;
int fSkInCount = 1;
// Holds a list of uniforms that were declared as globals at the top-level instead of in an
// interface block.
std::vector<const VarDeclaration*> fTopLevelUniforms;
std::unordered_map<const Variable*, int> fTopLevelUniformMap; //<var, UniformBuffer field index>
SpvId fUniformBufferId = -1;
friend class PointerLValue;
friend class SwizzleLValue;

View File

@ -243,7 +243,8 @@ public:
/**
* For matrices and vectors, returns the type of individual cells (e.g. mat2 has a component
* type of Float). For all other types, returns the type itself.
* type of Float). For arrays, returns the base type. For all other types, returns the type
* itself.
*/
const Type& componentType() const {
if (fComponentType) {

View File

@ -1,10 +1,3 @@
### Compilation failed:
error: SPIR-V validation error: Uniform OpVariable <id> '10[%colorXform]' has illegal type.
From Vulkan spec, section 14.5.2:
Variables identified with the Uniform storage class are used to access transparent buffer backed resources. Such variables must be typed as OpTypeStruct, or an array of this type
%colorXform = OpVariable %_ptr_Uniform_mat4v4float Uniform
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@ -12,8 +5,9 @@ OpEntryPoint Fragment %main "main" %sk_FragColor %sk_Clockwise
OpExecutionMode %main OriginUpperLeft
OpName %sk_FragColor "sk_FragColor"
OpName %sk_Clockwise "sk_Clockwise"
OpName %colorXform "colorXform"
OpName %s "s"
OpName %_UniformBuffer "_UniformBuffer"
OpMemberName %_UniformBuffer 0 "colorXform"
OpName %main "main"
OpName %tmpColor "tmpColor"
OpDecorate %sk_FragColor RelaxedPrecision
@ -21,11 +15,17 @@ OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
OpDecorate %sk_Clockwise RelaxedPrecision
OpDecorate %sk_Clockwise BuiltIn FrontFacing
OpDecorate %colorXform DescriptorSet 0
OpDecorate %s RelaxedPrecision
OpDecorate %s Binding 0
OpDecorate %s DescriptorSet 0
OpDecorate %23 RelaxedPrecision
OpMemberDecorate %_UniformBuffer 0 DescriptorSet 0
OpMemberDecorate %_UniformBuffer 0 Offset 0
OpMemberDecorate %_UniformBuffer 0 ColMajor
OpMemberDecorate %_UniformBuffer 0 MatrixStride 16
OpDecorate %_UniformBuffer Block
OpDecorate %14 Binding 0
OpDecorate %14 DescriptorSet 0
OpDecorate %24 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
@ -33,87 +33,91 @@ OpDecorate %23 RelaxedPrecision
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
%13 = OpTypeImage %float 2D 0 0 0 1 Unknown
%12 = OpTypeSampledImage %13
%_ptr_UniformConstant_12 = OpTypePointer UniformConstant %12
%s = OpVariable %_ptr_UniformConstant_12 UniformConstant
%mat4v4float = OpTypeMatrix %v4float 4
%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float
%colorXform = OpVariable %_ptr_Uniform_mat4v4float Uniform
%16 = OpTypeImage %float 2D 0 0 0 1 Unknown
%15 = OpTypeSampledImage %16
%_ptr_UniformConstant_15 = OpTypePointer UniformConstant %15
%s = OpVariable %_ptr_UniformConstant_15 UniformConstant
%_UniformBuffer = OpTypeStruct %mat4v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%14 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%18 = OpTypeFunction %void
%19 = OpTypeFunction %void
%_ptr_Function_v4float = OpTypePointer Function %v4float
%v2float = OpTypeVector %float 2
%float_1 = OpConstant %float 1
%26 = OpConstantComposite %v2float %float_1 %float_1
%27 = OpConstantComposite %v2float %float_1 %float_1
%_ptr_Uniform_mat4v4float = OpTypePointer Uniform %mat4v4float
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%float_0 = OpConstant %float 0
%v4bool = OpTypeVector %bool 4
%v3float = OpTypeVector %float 3
%main = OpFunction %void None %18
%19 = OpLabel
%main = OpFunction %void None %19
%20 = OpLabel
%tmpColor = OpVariable %_ptr_Function_v4float Function
%54 = OpVariable %_ptr_Function_v4float Function
%23 = OpLoad %15 %s
%22 = OpImageSampleImplicitLod %v4float %23 %26
OpStore %tmpColor %22
%27 = OpLoad %mat4v4float %colorXform
%30 = OpCompositeConstruct %v4float %float_1 %float_0 %float_0 %float_0
%31 = OpCompositeConstruct %v4float %float_0 %float_1 %float_0 %float_0
%32 = OpCompositeConstruct %v4float %float_0 %float_0 %float_1 %float_0
%33 = OpCompositeConstruct %v4float %float_0 %float_0 %float_0 %float_1
%28 = OpCompositeConstruct %mat4v4float %30 %31 %32 %33
%35 = OpCompositeExtract %v4float %27 0
%36 = OpCompositeExtract %v4float %28 0
%37 = OpFOrdNotEqual %v4bool %35 %36
%38 = OpAny %bool %37
%39 = OpCompositeExtract %v4float %27 1
%40 = OpCompositeExtract %v4float %28 1
%41 = OpFOrdNotEqual %v4bool %39 %40
%42 = OpAny %bool %41
%43 = OpLogicalOr %bool %38 %42
%44 = OpCompositeExtract %v4float %27 2
%45 = OpCompositeExtract %v4float %28 2
%59 = OpVariable %_ptr_Function_v4float Function
%24 = OpLoad %12 %s
%23 = OpImageSampleImplicitLod %v4float %24 %27
OpStore %tmpColor %23
%28 = OpAccessChain %_ptr_Uniform_mat4v4float %14 %int_0
%32 = OpLoad %mat4v4float %28
%35 = OpCompositeConstruct %v4float %float_1 %float_0 %float_0 %float_0
%36 = OpCompositeConstruct %v4float %float_0 %float_1 %float_0 %float_0
%37 = OpCompositeConstruct %v4float %float_0 %float_0 %float_1 %float_0
%38 = OpCompositeConstruct %v4float %float_0 %float_0 %float_0 %float_1
%33 = OpCompositeConstruct %mat4v4float %35 %36 %37 %38
%40 = OpCompositeExtract %v4float %32 0
%41 = OpCompositeExtract %v4float %33 0
%42 = OpFOrdNotEqual %v4bool %40 %41
%43 = OpAny %bool %42
%44 = OpCompositeExtract %v4float %32 1
%45 = OpCompositeExtract %v4float %33 1
%46 = OpFOrdNotEqual %v4bool %44 %45
%47 = OpAny %bool %46
%48 = OpLogicalOr %bool %43 %47
%49 = OpCompositeExtract %v4float %27 3
%50 = OpCompositeExtract %v4float %28 3
%49 = OpCompositeExtract %v4float %32 2
%50 = OpCompositeExtract %v4float %33 2
%51 = OpFOrdNotEqual %v4bool %49 %50
%52 = OpAny %bool %51
%53 = OpLogicalOr %bool %48 %52
OpSelectionMerge %57 None
OpBranchConditional %53 %55 %56
%55 = OpLabel
%59 = OpLoad %mat4v4float %colorXform
%60 = OpLoad %v4float %tmpColor
%61 = OpVectorShuffle %v3float %60 %60 0 1 2
%63 = OpCompositeExtract %float %61 0
%64 = OpCompositeExtract %float %61 1
%65 = OpCompositeExtract %float %61 2
%66 = OpCompositeConstruct %v4float %63 %64 %65 %float_1
%67 = OpMatrixTimesVector %v4float %59 %66
%68 = OpVectorShuffle %v3float %67 %67 0 1 2
%69 = OpCompositeConstruct %v3float %float_0 %float_0 %float_0
%70 = OpLoad %v4float %tmpColor
%71 = OpCompositeExtract %float %70 3
%72 = OpCompositeConstruct %v3float %71 %71 %71
%58 = OpExtInst %v3float %1 FClamp %68 %69 %72
%73 = OpCompositeExtract %float %58 0
%74 = OpCompositeExtract %float %58 1
%75 = OpCompositeExtract %float %58 2
%54 = OpCompositeExtract %v4float %32 3
%55 = OpCompositeExtract %v4float %33 3
%56 = OpFOrdNotEqual %v4bool %54 %55
%57 = OpAny %bool %56
%58 = OpLogicalOr %bool %53 %57
OpSelectionMerge %62 None
OpBranchConditional %58 %60 %61
%60 = OpLabel
%64 = OpAccessChain %_ptr_Uniform_mat4v4float %14 %int_0
%65 = OpLoad %mat4v4float %64
%66 = OpLoad %v4float %tmpColor
%67 = OpVectorShuffle %v3float %66 %66 0 1 2
%69 = OpCompositeExtract %float %67 0
%70 = OpCompositeExtract %float %67 1
%71 = OpCompositeExtract %float %67 2
%72 = OpCompositeConstruct %v4float %69 %70 %71 %float_1
%73 = OpMatrixTimesVector %v4float %65 %72
%74 = OpVectorShuffle %v3float %73 %73 0 1 2
%75 = OpCompositeConstruct %v3float %float_0 %float_0 %float_0
%76 = OpLoad %v4float %tmpColor
%77 = OpCompositeExtract %float %76 3
%78 = OpCompositeConstruct %v4float %73 %74 %75 %77
OpStore %54 %78
OpBranch %57
%56 = OpLabel
%79 = OpLoad %v4float %tmpColor
OpStore %54 %79
OpBranch %57
%57 = OpLabel
%80 = OpLoad %v4float %54
OpStore %sk_FragColor %80
%78 = OpCompositeConstruct %v3float %77 %77 %77
%63 = OpExtInst %v3float %1 FClamp %74 %75 %78
%79 = OpCompositeExtract %float %63 0
%80 = OpCompositeExtract %float %63 1
%81 = OpCompositeExtract %float %63 2
%82 = OpLoad %v4float %tmpColor
%83 = OpCompositeExtract %float %82 3
%84 = OpCompositeConstruct %v4float %79 %80 %81 %83
OpStore %59 %84
OpBranch %62
%61 = OpLabel
%85 = OpLoad %v4float %tmpColor
OpStore %59 %85
OpBranch %62
%62 = OpLabel
%86 = OpLoad %v4float %59
OpStore %sk_FragColor %86
OpReturn
OpFunctionEnd
1 error

View File

@ -1,10 +1,3 @@
### Compilation failed:
error: SPIR-V validation error: Uniform OpVariable <id> '10[%colorWhite]' has illegal type.
From Vulkan spec, section 14.5.2:
Variables identified with the Uniform storage class are used to access transparent buffer backed resources. Such variables must be typed as OpTypeStruct, or an array of this type
%colorWhite = OpVariable %_ptr_Uniform_v4float Uniform
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@ -12,7 +5,8 @@ OpEntryPoint Fragment %_entrypoint "_entrypoint" %sk_FragColor %sk_Clockwise
OpExecutionMode %_entrypoint OriginUpperLeft
OpName %sk_FragColor "sk_FragColor"
OpName %sk_Clockwise "sk_Clockwise"
OpName %colorWhite "colorWhite"
OpName %_UniformBuffer "_UniformBuffer"
OpMemberName %_UniformBuffer 0 "colorWhite"
OpName %_entrypoint "_entrypoint"
OpName %main "main"
OpName %x "x"
@ -23,20 +17,23 @@ OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
OpDecorate %sk_Clockwise RelaxedPrecision
OpDecorate %sk_Clockwise BuiltIn FrontFacing
OpDecorate %colorWhite RelaxedPrecision
OpDecorate %colorWhite DescriptorSet 0
OpDecorate %21 RelaxedPrecision
OpDecorate %30 RelaxedPrecision
OpDecorate %34 RelaxedPrecision
OpDecorate %40 RelaxedPrecision
OpDecorate %45 RelaxedPrecision
OpDecorate %46 RelaxedPrecision
OpDecorate %53 RelaxedPrecision
OpDecorate %55 RelaxedPrecision
OpMemberDecorate %_UniformBuffer 0 Offset 0
OpMemberDecorate %_UniformBuffer 0 RelaxedPrecision
OpDecorate %_UniformBuffer Block
OpDecorate %10 Binding 0
OpDecorate %10 DescriptorSet 0
OpDecorate %26 RelaxedPrecision
OpDecorate %35 RelaxedPrecision
OpDecorate %39 RelaxedPrecision
OpDecorate %43 RelaxedPrecision
OpDecorate %48 RelaxedPrecision
OpDecorate %49 RelaxedPrecision
OpDecorate %56 RelaxedPrecision
OpDecorate %58 RelaxedPrecision
OpDecorate %65 RelaxedPrecision
OpDecorate %66 RelaxedPrecision
OpDecorate %67 RelaxedPrecision
OpDecorate %61 RelaxedPrecision
OpDecorate %68 RelaxedPrecision
OpDecorate %69 RelaxedPrecision
OpDecorate %70 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
@ -44,95 +41,96 @@ OpDecorate %67 RelaxedPrecision
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%colorWhite = OpVariable %_ptr_Uniform_v4float Uniform
%_UniformBuffer = OpTypeStruct %v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%10 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%14 = OpTypeFunction %void
%17 = OpTypeFunction %v4float
%15 = OpTypeFunction %void
%18 = OpTypeFunction %v4float
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_Function_float = OpTypePointer Function %float
%float_n5 = OpConstant %float -5
%float_5 = OpConstant %float 5
%float_0 = OpConstant %float 0
%float_1 = OpConstant %float 1
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%int_2 = OpConstant %int 2
%int_1 = OpConstant %int 1
%_entrypoint = OpFunction %void None %14
%15 = OpLabel
%16 = OpFunctionCall %v4float %main
OpStore %sk_FragColor %16
%_entrypoint = OpFunction %void None %15
%16 = OpLabel
%17 = OpFunctionCall %v4float %main
OpStore %sk_FragColor %17
OpReturn
OpFunctionEnd
%main = OpFunction %v4float None %17
%18 = OpLabel
%main = OpFunction %v4float None %18
%19 = OpLabel
%x = OpVariable %_ptr_Function_v4float Function
%r = OpVariable %_ptr_Function_float Function
%b = OpVariable %_ptr_Function_float Function
%21 = OpLoad %v4float %colorWhite
OpStore %x %21
%22 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
%26 = OpLoad %v4float %22
OpStore %x %26
OpStore %r %float_n5
OpBranch %25
%25 = OpLabel
OpLoopMerge %29 %28 None
OpBranch %26
%26 = OpLabel
%30 = OpLoad %float %r
%32 = OpFOrdLessThan %bool %30 %float_5
OpBranchConditional %32 %27 %29
%27 = OpLabel
%34 = OpLoad %float %r
%33 = OpExtInst %float %1 FClamp %34 %float_0 %float_1
%37 = OpAccessChain %_ptr_Function_float %x %int_0
OpStore %37 %33
%40 = OpLoad %v4float %x
%41 = OpCompositeExtract %float %40 0
%42 = OpFOrdEqual %bool %41 %float_0
OpSelectionMerge %44 None
OpBranchConditional %42 %43 %44
%43 = OpLabel
OpBranch %29
%44 = OpLabel
OpBranch %28
%28 = OpLabel
%45 = OpLoad %float %r
%46 = OpFAdd %float %45 %float_1
OpStore %r %46
OpBranch %25
%29 = OpLabel
OpBranch %30
%30 = OpLabel
OpLoopMerge %34 %33 None
OpBranch %31
%31 = OpLabel
%35 = OpLoad %float %r
%37 = OpFOrdLessThan %bool %35 %float_5
OpBranchConditional %37 %32 %34
%32 = OpLabel
%39 = OpLoad %float %r
%38 = OpExtInst %float %1 FClamp %39 %float_0 %float_1
%42 = OpAccessChain %_ptr_Function_float %x %int_0
OpStore %42 %38
%43 = OpLoad %v4float %x
%44 = OpCompositeExtract %float %43 0
%45 = OpFOrdEqual %bool %44 %float_0
OpSelectionMerge %47 None
OpBranchConditional %45 %46 %47
%46 = OpLabel
OpBranch %34
%47 = OpLabel
OpBranch %33
%33 = OpLabel
%48 = OpLoad %float %r
%49 = OpFAdd %float %48 %float_1
OpStore %r %49
OpBranch %30
%34 = OpLabel
OpStore %b %float_5
OpBranch %48
%48 = OpLabel
OpLoopMerge %52 %51 None
OpBranch %49
%49 = OpLabel
%53 = OpLoad %float %b
%54 = OpFOrdGreaterThanEqual %bool %53 %float_0
OpBranchConditional %54 %50 %52
%50 = OpLabel
%55 = OpLoad %float %b
%56 = OpAccessChain %_ptr_Function_float %x %int_2
OpStore %56 %55
%58 = OpLoad %v4float %x
%59 = OpCompositeExtract %float %58 3
%60 = OpFOrdEqual %bool %59 %float_1
OpSelectionMerge %62 None
OpBranchConditional %60 %61 %62
%61 = OpLabel
OpBranch %51
%62 = OpLabel
%63 = OpAccessChain %_ptr_Function_float %x %int_1
OpStore %63 %float_0
OpBranch %51
%51 = OpLabel
%65 = OpLoad %float %b
%66 = OpFSub %float %65 %float_1
OpStore %b %66
OpBranch %48
OpLoopMerge %55 %54 None
OpBranch %52
%52 = OpLabel
%67 = OpLoad %v4float %x
OpReturnValue %67
%56 = OpLoad %float %b
%57 = OpFOrdGreaterThanEqual %bool %56 %float_0
OpBranchConditional %57 %53 %55
%53 = OpLabel
%58 = OpLoad %float %b
%59 = OpAccessChain %_ptr_Function_float %x %int_2
OpStore %59 %58
%61 = OpLoad %v4float %x
%62 = OpCompositeExtract %float %61 3
%63 = OpFOrdEqual %bool %62 %float_1
OpSelectionMerge %65 None
OpBranchConditional %63 %64 %65
%64 = OpLabel
OpBranch %54
%65 = OpLabel
%66 = OpAccessChain %_ptr_Function_float %x %int_1
OpStore %66 %float_0
OpBranch %54
%54 = OpLabel
%68 = OpLoad %float %b
%69 = OpFSub %float %68 %float_1
OpStore %b %69
OpBranch %51
%55 = OpLabel
%70 = OpLoad %v4float %x
OpReturnValue %70
OpFunctionEnd
1 error

View File

@ -1,10 +1,3 @@
### Compilation failed:
error: SPIR-V validation error: Uniform OpVariable <id> '8[%sk_RTAdjust]' has illegal type.
From Vulkan spec, section 14.5.2:
Variables identified with the Uniform storage class are used to access transparent buffer backed resources. Such variables must be typed as OpTypeStruct, or an array of this type
%sk_RTAdjust = OpVariable %_ptr_Uniform_v4float Uniform
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@ -12,56 +5,63 @@ OpEntryPoint Vertex %main "main" %3 %pos
OpName %sk_PerVertex "sk_PerVertex"
OpMemberName %sk_PerVertex 0 "sk_Position"
OpMemberName %sk_PerVertex 1 "sk_PointSize"
OpName %sk_RTAdjust "sk_RTAdjust"
OpName %pos "pos"
OpName %_UniformBuffer "_UniformBuffer"
OpMemberName %_UniformBuffer 0 "sk_RTAdjust"
OpName %main "main"
OpMemberDecorate %sk_PerVertex 0 BuiltIn Position
OpMemberDecorate %sk_PerVertex 1 BuiltIn PointSize
OpDecorate %sk_PerVertex Block
OpDecorate %sk_RTAdjust DescriptorSet 0
OpMemberDecorate %_UniformBuffer 0 DescriptorSet 0
OpMemberDecorate %_UniformBuffer 0 Offset 0
OpDecorate %_UniformBuffer Block
OpDecorate %10 Binding 0
OpDecorate %10 DescriptorSet 0
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%sk_PerVertex = OpTypeStruct %v4float %float
%_ptr_Output_sk_PerVertex = OpTypePointer Output %sk_PerVertex
%3 = OpVariable %_ptr_Output_sk_PerVertex Output
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%sk_RTAdjust = OpVariable %_ptr_Uniform_v4float Uniform
%_ptr_Input_v4float = OpTypePointer Input %v4float
%pos = OpVariable %_ptr_Input_v4float Input
%_UniformBuffer = OpTypeStruct %v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%10 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%13 = OpTypeFunction %void
%14 = OpTypeFunction %void
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_Output_v4float = OpTypePointer Output %v4float
%v2float = OpTypeVector %float 2
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%float_0 = OpConstant %float 0
%main = OpFunction %void None %13
%14 = OpLabel
%15 = OpLoad %v4float %pos
%18 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %18 %15
%20 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%21 = OpLoad %v4float %20
%22 = OpVectorShuffle %v2float %21 %21 0 1
%24 = OpLoad %v4float %sk_RTAdjust
%25 = OpVectorShuffle %v2float %24 %24 0 2
%26 = OpFMul %v2float %22 %25
%27 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%28 = OpLoad %v4float %27
%29 = OpVectorShuffle %v2float %28 %28 3 3
%30 = OpLoad %v4float %sk_RTAdjust
%31 = OpVectorShuffle %v2float %30 %30 1 3
%32 = OpFMul %v2float %29 %31
%33 = OpFAdd %v2float %26 %32
%34 = OpCompositeExtract %float %33 0
%35 = OpCompositeExtract %float %33 1
%37 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%38 = OpLoad %v4float %37
%39 = OpCompositeExtract %float %38 3
%40 = OpCompositeConstruct %v4float %34 %35 %float_0 %39
%main = OpFunction %void None %14
%15 = OpLabel
%16 = OpLoad %v4float %pos
%19 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %19 %16
%21 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%22 = OpLoad %v4float %21
%23 = OpVectorShuffle %v2float %22 %22 0 1
%25 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
%27 = OpLoad %v4float %25
%28 = OpVectorShuffle %v2float %27 %27 0 2
%29 = OpFMul %v2float %23 %28
%30 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%31 = OpLoad %v4float %30
%32 = OpVectorShuffle %v2float %31 %31 3 3
%33 = OpAccessChain %_ptr_Uniform_v4float %10 %int_0
%34 = OpLoad %v4float %33
%35 = OpVectorShuffle %v2float %34 %34 1 3
%36 = OpFMul %v2float %32 %35
%37 = OpFAdd %v2float %29 %36
%38 = OpCompositeExtract %float %37 0
%39 = OpCompositeExtract %float %37 1
%41 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %41 %40
%42 = OpLoad %v4float %41
%43 = OpCompositeExtract %float %42 3
%44 = OpCompositeConstruct %v4float %38 %39 %float_0 %43
%45 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %45 %44
OpReturn
OpFunctionEnd
1 error

View File

@ -1,10 +1,3 @@
### Compilation failed:
error: SPIR-V validation error: Uniform OpVariable <id> '15[%sk_RTAdjust]' has illegal type.
From Vulkan spec, section 14.5.2:
Variables identified with the Uniform storage class are used to access transparent buffer backed resources. Such variables must be typed as OpTypeStruct, or an array of this type
%sk_RTAdjust = OpVariable %_ptr_Uniform_v4float Uniform
OpCapability Geometry
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@ -17,13 +10,17 @@ OpName %sk_PerVertex "sk_PerVertex"
OpMemberName %sk_PerVertex 0 "sk_Position"
OpMemberName %sk_PerVertex 1 "sk_PointSize"
OpName %sk_InvocationID "sk_InvocationID"
OpName %sk_RTAdjust "sk_RTAdjust"
OpName %_UniformBuffer "_UniformBuffer"
OpMemberName %_UniformBuffer 0 "sk_RTAdjust"
OpName %main "main"
OpMemberDecorate %sk_PerVertex 0 BuiltIn Position
OpMemberDecorate %sk_PerVertex 1 BuiltIn PointSize
OpDecorate %_arr_sk_PerVertex_int_1 ArrayStride 32
OpDecorate %sk_InvocationID BuiltIn InvocationId
OpDecorate %sk_RTAdjust DescriptorSet 0
OpMemberDecorate %_UniformBuffer 0 Offset 0
OpDecorate %_UniformBuffer Block
OpDecorate %15 Binding 0
OpDecorate %15 DescriptorSet 0
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%sk_PerVertex = OpTypeStruct %v4float %float
@ -36,81 +33,85 @@ OpDecorate %sk_RTAdjust DescriptorSet 0
%8 = OpVariable %_ptr_Input__arr_sk_PerVertex_int_1 Input
%_ptr_Input_int = OpTypePointer Input %int
%sk_InvocationID = OpVariable %_ptr_Input_int Input
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%sk_RTAdjust = OpVariable %_ptr_Uniform_v4float Uniform
%_UniformBuffer = OpTypeStruct %v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%15 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%18 = OpTypeFunction %void
%19 = OpTypeFunction %void
%int_0 = OpConstant %int 0
%_ptr_Input_v4float = OpTypePointer Input %v4float
%float_n0_5 = OpConstant %float -0.5
%float_0 = OpConstant %float 0
%_ptr_Output_v4float = OpTypePointer Output %v4float
%v2float = OpTypeVector %float 2
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%float_0_5 = OpConstant %float 0.5
%main = OpFunction %void None %18
%19 = OpLabel
%21 = OpAccessChain %_ptr_Input_v4float %8 %int_0 %int_0
%23 = OpLoad %v4float %21
%26 = OpLoad %int %sk_InvocationID
%27 = OpConvertSToF %float %26
%28 = OpCompositeConstruct %v4float %float_n0_5 %float_0 %float_0 %27
%29 = OpFAdd %v4float %23 %28
%30 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %30 %29
%32 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%33 = OpLoad %v4float %32
%34 = OpVectorShuffle %v2float %33 %33 0 1
%36 = OpLoad %v4float %sk_RTAdjust
%37 = OpVectorShuffle %v2float %36 %36 0 2
%38 = OpFMul %v2float %34 %37
%39 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%40 = OpLoad %v4float %39
%41 = OpVectorShuffle %v2float %40 %40 3 3
%42 = OpLoad %v4float %sk_RTAdjust
%43 = OpVectorShuffle %v2float %42 %42 1 3
%44 = OpFMul %v2float %41 %43
%45 = OpFAdd %v2float %38 %44
%46 = OpCompositeExtract %float %45 0
%47 = OpCompositeExtract %float %45 1
%48 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%49 = OpLoad %v4float %48
%50 = OpCompositeExtract %float %49 3
%51 = OpCompositeConstruct %v4float %46 %47 %float_0 %50
%main = OpFunction %void None %19
%20 = OpLabel
%22 = OpAccessChain %_ptr_Input_v4float %8 %int_0 %int_0
%24 = OpLoad %v4float %22
%27 = OpLoad %int %sk_InvocationID
%28 = OpConvertSToF %float %27
%29 = OpCompositeConstruct %v4float %float_n0_5 %float_0 %float_0 %28
%30 = OpFAdd %v4float %24 %29
%31 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %31 %30
%33 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%34 = OpLoad %v4float %33
%35 = OpVectorShuffle %v2float %34 %34 0 1
%37 = OpAccessChain %_ptr_Uniform_v4float %15 %int_0
%39 = OpLoad %v4float %37
%40 = OpVectorShuffle %v2float %39 %39 0 2
%41 = OpFMul %v2float %35 %40
%42 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%43 = OpLoad %v4float %42
%44 = OpVectorShuffle %v2float %43 %43 3 3
%45 = OpAccessChain %_ptr_Uniform_v4float %15 %int_0
%46 = OpLoad %v4float %45
%47 = OpVectorShuffle %v2float %46 %46 1 3
%48 = OpFMul %v2float %44 %47
%49 = OpFAdd %v2float %41 %48
%50 = OpCompositeExtract %float %49 0
%51 = OpCompositeExtract %float %49 1
%52 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %52 %51
%53 = OpLoad %v4float %52
%54 = OpCompositeExtract %float %53 3
%55 = OpCompositeConstruct %v4float %50 %51 %float_0 %54
%56 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %56 %55
OpEmitVertex
%54 = OpAccessChain %_ptr_Input_v4float %8 %int_0 %int_0
%55 = OpLoad %v4float %54
%57 = OpLoad %int %sk_InvocationID
%58 = OpConvertSToF %float %57
%59 = OpCompositeConstruct %v4float %float_0_5 %float_0 %float_0 %58
%60 = OpFAdd %v4float %55 %59
%61 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %61 %60
%62 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%63 = OpLoad %v4float %62
%64 = OpVectorShuffle %v2float %63 %63 0 1
%65 = OpLoad %v4float %sk_RTAdjust
%66 = OpVectorShuffle %v2float %65 %65 0 2
%67 = OpFMul %v2float %64 %66
%68 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%69 = OpLoad %v4float %68
%70 = OpVectorShuffle %v2float %69 %69 3 3
%71 = OpLoad %v4float %sk_RTAdjust
%72 = OpVectorShuffle %v2float %71 %71 1 3
%73 = OpFMul %v2float %70 %72
%74 = OpFAdd %v2float %67 %73
%75 = OpCompositeExtract %float %74 0
%76 = OpCompositeExtract %float %74 1
%77 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%78 = OpLoad %v4float %77
%79 = OpCompositeExtract %float %78 3
%80 = OpCompositeConstruct %v4float %75 %76 %float_0 %79
%81 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %81 %80
%58 = OpAccessChain %_ptr_Input_v4float %8 %int_0 %int_0
%59 = OpLoad %v4float %58
%61 = OpLoad %int %sk_InvocationID
%62 = OpConvertSToF %float %61
%63 = OpCompositeConstruct %v4float %float_0_5 %float_0 %float_0 %62
%64 = OpFAdd %v4float %59 %63
%65 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %65 %64
%66 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%67 = OpLoad %v4float %66
%68 = OpVectorShuffle %v2float %67 %67 0 1
%69 = OpAccessChain %_ptr_Uniform_v4float %15 %int_0
%70 = OpLoad %v4float %69
%71 = OpVectorShuffle %v2float %70 %70 0 2
%72 = OpFMul %v2float %68 %71
%73 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%74 = OpLoad %v4float %73
%75 = OpVectorShuffle %v2float %74 %74 3 3
%76 = OpAccessChain %_ptr_Uniform_v4float %15 %int_0
%77 = OpLoad %v4float %76
%78 = OpVectorShuffle %v2float %77 %77 1 3
%79 = OpFMul %v2float %75 %78
%80 = OpFAdd %v2float %72 %79
%81 = OpCompositeExtract %float %80 0
%82 = OpCompositeExtract %float %80 1
%83 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%84 = OpLoad %v4float %83
%85 = OpCompositeExtract %float %84 3
%86 = OpCompositeConstruct %v4float %81 %82 %float_0 %85
%87 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %87 %86
OpEmitVertex
OpEndPrimitive
OpReturn
OpFunctionEnd
1 error

View File

@ -1,10 +1,3 @@
### Compilation failed:
error: SPIR-V validation error: Uniform OpVariable <id> '8[%sk_RTAdjust]' has illegal type.
From Vulkan spec, section 14.5.2:
Variables identified with the Uniform storage class are used to access transparent buffer backed resources. Such variables must be typed as OpTypeStruct, or an array of this type
%sk_RTAdjust = OpVariable %_ptr_Uniform_v4float Uniform
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@ -12,54 +5,61 @@ OpEntryPoint Vertex %main "main" %3
OpName %sk_PerVertex "sk_PerVertex"
OpMemberName %sk_PerVertex 0 "sk_Position"
OpMemberName %sk_PerVertex 1 "sk_PointSize"
OpName %sk_RTAdjust "sk_RTAdjust"
OpName %_UniformBuffer "_UniformBuffer"
OpMemberName %_UniformBuffer 0 "sk_RTAdjust"
OpName %main "main"
OpMemberDecorate %sk_PerVertex 0 BuiltIn Position
OpMemberDecorate %sk_PerVertex 1 BuiltIn PointSize
OpDecorate %sk_PerVertex Block
OpDecorate %sk_RTAdjust DescriptorSet 0
OpMemberDecorate %_UniformBuffer 0 DescriptorSet 0
OpMemberDecorate %_UniformBuffer 0 Offset 0
OpDecorate %_UniformBuffer Block
OpDecorate %8 Binding 0
OpDecorate %8 DescriptorSet 0
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%sk_PerVertex = OpTypeStruct %v4float %float
%_ptr_Output_sk_PerVertex = OpTypePointer Output %sk_PerVertex
%3 = OpVariable %_ptr_Output_sk_PerVertex Output
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%sk_RTAdjust = OpVariable %_ptr_Uniform_v4float Uniform
%_UniformBuffer = OpTypeStruct %v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%8 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%11 = OpTypeFunction %void
%12 = OpTypeFunction %void
%float_1 = OpConstant %float 1
%14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%15 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_Output_v4float = OpTypePointer Output %v4float
%v2float = OpTypeVector %float 2
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%float_0 = OpConstant %float 0
%main = OpFunction %void None %11
%12 = OpLabel
%17 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %17 %14
%19 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%20 = OpLoad %v4float %19
%21 = OpVectorShuffle %v2float %20 %20 0 1
%23 = OpLoad %v4float %sk_RTAdjust
%24 = OpVectorShuffle %v2float %23 %23 0 2
%25 = OpFMul %v2float %21 %24
%26 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%27 = OpLoad %v4float %26
%28 = OpVectorShuffle %v2float %27 %27 3 3
%29 = OpLoad %v4float %sk_RTAdjust
%30 = OpVectorShuffle %v2float %29 %29 1 3
%31 = OpFMul %v2float %28 %30
%32 = OpFAdd %v2float %25 %31
%33 = OpCompositeExtract %float %32 0
%34 = OpCompositeExtract %float %32 1
%36 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%37 = OpLoad %v4float %36
%38 = OpCompositeExtract %float %37 3
%39 = OpCompositeConstruct %v4float %33 %34 %float_0 %38
%main = OpFunction %void None %12
%13 = OpLabel
%18 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %18 %15
%20 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%21 = OpLoad %v4float %20
%22 = OpVectorShuffle %v2float %21 %21 0 1
%24 = OpAccessChain %_ptr_Uniform_v4float %8 %int_0
%26 = OpLoad %v4float %24
%27 = OpVectorShuffle %v2float %26 %26 0 2
%28 = OpFMul %v2float %22 %27
%29 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%30 = OpLoad %v4float %29
%31 = OpVectorShuffle %v2float %30 %30 3 3
%32 = OpAccessChain %_ptr_Uniform_v4float %8 %int_0
%33 = OpLoad %v4float %32
%34 = OpVectorShuffle %v2float %33 %33 1 3
%35 = OpFMul %v2float %31 %34
%36 = OpFAdd %v2float %28 %35
%37 = OpCompositeExtract %float %36 0
%38 = OpCompositeExtract %float %36 1
%40 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %40 %39
%41 = OpLoad %v4float %40
%42 = OpCompositeExtract %float %41 3
%43 = OpCompositeConstruct %v4float %37 %38 %float_0 %42
%44 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %44 %43
OpReturn
OpFunctionEnd
1 error

View File

@ -1,10 +1,3 @@
### Compilation failed:
error: SPIR-V validation error: Uniform OpVariable <id> '13[%colorRed]' has illegal type.
From Vulkan spec, section 14.5.2:
Variables identified with the Uniform storage class are used to access transparent buffer backed resources. Such variables must be typed as OpTypeStruct, or an array of this type
%colorRed = OpVariable %_ptr_Uniform_v4float Uniform
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@ -12,8 +5,9 @@ OpEntryPoint Fragment %_entrypoint "_entrypoint" %sk_FragColor %sk_Clockwise
OpExecutionMode %_entrypoint OriginUpperLeft
OpName %sk_FragColor "sk_FragColor"
OpName %sk_Clockwise "sk_Clockwise"
OpName %colorRed "colorRed"
OpName %colorGreen "colorGreen"
OpName %_UniformBuffer "_UniformBuffer"
OpMemberName %_UniformBuffer 0 "colorRed"
OpMemberName %_UniformBuffer 1 "colorGreen"
OpName %_entrypoint "_entrypoint"
OpName %S "S"
OpMemberName %S 0 "x"
@ -31,18 +25,21 @@ OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
OpDecorate %sk_Clockwise RelaxedPrecision
OpDecorate %sk_Clockwise BuiltIn FrontFacing
OpDecorate %colorRed RelaxedPrecision
OpDecorate %colorRed DescriptorSet 0
OpDecorate %colorGreen RelaxedPrecision
OpDecorate %colorGreen DescriptorSet 0
OpMemberDecorate %_UniformBuffer 0 Offset 0
OpMemberDecorate %_UniformBuffer 0 RelaxedPrecision
OpMemberDecorate %_UniformBuffer 1 Offset 16
OpMemberDecorate %_UniformBuffer 1 RelaxedPrecision
OpDecorate %_UniformBuffer Block
OpDecorate %13 Binding 0
OpDecorate %13 DescriptorSet 0
OpMemberDecorate %S 0 Offset 0
OpMemberDecorate %S 1 Offset 4
OpDecorate %35 RelaxedPrecision
OpDecorate %59 RelaxedPrecision
OpDecorate %83 RelaxedPrecision
OpDecorate %89 RelaxedPrecision
OpDecorate %90 RelaxedPrecision
OpDecorate %91 RelaxedPrecision
OpDecorate %93 RelaxedPrecision
OpDecorate %94 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
@ -50,9 +47,9 @@ OpDecorate %91 RelaxedPrecision
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%colorRed = OpVariable %_ptr_Uniform_v4float Uniform
%colorGreen = OpVariable %_ptr_Uniform_v4float Uniform
%_UniformBuffer = OpTypeStruct %v4float %v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%13 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%18 = OpTypeFunction %void
%int = OpTypeInt 32 1
@ -74,6 +71,7 @@ OpDecorate %91 RelaxedPrecision
%float_2 = OpConstant %float 2
%int_3 = OpConstant %int 3
%_ptr_Function_v4float = OpTypePointer Function %v4float
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%_entrypoint = OpFunction %void None %18
%19 = OpLabel
%20 = OpFunctionCall %v4float %main
@ -153,16 +151,16 @@ OpStore %valid %82
OpSelectionMerge %88 None
OpBranchConditional %83 %86 %87
%86 = OpLabel
%89 = OpLoad %v4float %colorGreen
OpStore %84 %89
%89 = OpAccessChain %_ptr_Uniform_v4float %13 %int_1
%91 = OpLoad %v4float %89
OpStore %84 %91
OpBranch %88
%87 = OpLabel
%90 = OpLoad %v4float %colorRed
OpStore %84 %90
%92 = OpAccessChain %_ptr_Uniform_v4float %13 %int_0
%93 = OpLoad %v4float %92
OpStore %84 %93
OpBranch %88
%88 = OpLabel
%91 = OpLoad %v4float %84
OpReturnValue %91
%94 = OpLoad %v4float %84
OpReturnValue %94
OpFunctionEnd
1 error

View File

@ -1,22 +1,19 @@
### Compilation failed:
error: SPIR-V validation error: Uniform OpVariable <id> '6[%arr]' has illegal type.
From Vulkan spec, section 14.5.2:
Variables identified with the Uniform storage class are used to access transparent buffer backed resources. Such variables must be typed as OpTypeStruct, or an array of this type
%arr = OpVariable %_ptr_Uniform__arr_float_int_3 Uniform
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %sk_Clockwise
OpExecutionMode %main OriginUpperLeft
OpName %sk_Clockwise "sk_Clockwise"
OpName %arr "arr"
OpName %_UniformBuffer "_UniformBuffer"
OpMemberName %_UniformBuffer 0 "arr"
OpName %main "main"
OpDecorate %sk_Clockwise RelaxedPrecision
OpDecorate %sk_Clockwise BuiltIn FrontFacing
OpDecorate %_arr_float_int_3 ArrayStride 16
OpDecorate %arr DescriptorSet 0
OpMemberDecorate %_UniformBuffer 0 Offset 0
OpDecorate %_UniformBuffer Block
OpDecorate %6 Binding 0
OpDecorate %6 DescriptorSet 0
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
@ -24,13 +21,12 @@ OpDecorate %arr DescriptorSet 0
%int = OpTypeInt 32 1
%int_3 = OpConstant %int 3
%_arr_float_int_3 = OpTypeArray %float %int_3
%_ptr_Uniform__arr_float_int_3 = OpTypePointer Uniform %_arr_float_int_3
%arr = OpVariable %_ptr_Uniform__arr_float_int_3 Uniform
%_UniformBuffer = OpTypeStruct %_arr_float_int_3
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%6 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%13 = OpTypeFunction %void
%main = OpFunction %void None %13
%14 = OpLabel
%14 = OpTypeFunction %void
%main = OpFunction %void None %14
%15 = OpLabel
OpReturn
OpFunctionEnd
1 error

View File

@ -1,10 +1,3 @@
### Compilation failed:
error: SPIR-V validation error: Uniform OpVariable <id> '10[%myHalf]' has illegal type.
From Vulkan spec, section 14.5.2:
Variables identified with the Uniform storage class are used to access transparent buffer backed resources. Such variables must be typed as OpTypeStruct, or an array of this type
%myHalf = OpVariable %_ptr_Uniform_float Uniform
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@ -12,8 +5,9 @@ OpEntryPoint Fragment %_entrypoint "_entrypoint" %sk_FragColor %sk_Clockwise
OpExecutionMode %_entrypoint OriginUpperLeft
OpName %sk_FragColor "sk_FragColor"
OpName %sk_Clockwise "sk_Clockwise"
OpName %myHalf "myHalf"
OpName %myHalf4 "myHalf4"
OpName %_UniformBuffer "_UniformBuffer"
OpMemberName %_UniformBuffer 0 "myHalf"
OpMemberName %_UniformBuffer 1 "myHalf4"
OpName %_entrypoint "_entrypoint"
OpName %main "main"
OpDecorate %sk_FragColor RelaxedPrecision
@ -21,12 +15,15 @@ OpDecorate %sk_FragColor Location 0
OpDecorate %sk_FragColor Index 0
OpDecorate %sk_Clockwise RelaxedPrecision
OpDecorate %sk_Clockwise BuiltIn FrontFacing
OpDecorate %myHalf RelaxedPrecision
OpDecorate %myHalf DescriptorSet 0
OpDecorate %myHalf4 RelaxedPrecision
OpDecorate %myHalf4 DescriptorSet 0
OpDecorate %21 RelaxedPrecision
OpDecorate %22 RelaxedPrecision
OpMemberDecorate %_UniformBuffer 0 Offset 0
OpMemberDecorate %_UniformBuffer 0 RelaxedPrecision
OpMemberDecorate %_UniformBuffer 1 Offset 16
OpMemberDecorate %_UniformBuffer 1 RelaxedPrecision
OpDecorate %_UniformBuffer Block
OpDecorate %10 Binding 0
OpDecorate %10 DescriptorSet 0
OpDecorate %24 RelaxedPrecision
OpDecorate %28 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
@ -34,25 +31,29 @@ OpDecorate %22 RelaxedPrecision
%bool = OpTypeBool
%_ptr_Input_bool = OpTypePointer Input %bool
%sk_Clockwise = OpVariable %_ptr_Input_bool Input
%_ptr_Uniform_float = OpTypePointer Uniform %float
%myHalf = OpVariable %_ptr_Uniform_float Uniform
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%myHalf4 = OpVariable %_ptr_Uniform_v4float Uniform
%_UniformBuffer = OpTypeStruct %float %v4float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%10 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%16 = OpTypeFunction %void
%19 = OpTypeFunction %v4float
%_entrypoint = OpFunction %void None %16
%17 = OpLabel
%18 = OpFunctionCall %v4float %main
OpStore %sk_FragColor %18
%15 = OpTypeFunction %void
%18 = OpTypeFunction %v4float
%_ptr_Uniform_v4float = OpTypePointer Uniform %v4float
%int = OpTypeInt 32 1
%int_1 = OpConstant %int 1
%_ptr_Uniform_float = OpTypePointer Uniform %float
%int_0 = OpConstant %int 0
%_entrypoint = OpFunction %void None %15
%16 = OpLabel
%17 = OpFunctionCall %v4float %main
OpStore %sk_FragColor %17
OpReturn
OpFunctionEnd
%main = OpFunction %v4float None %19
%20 = OpLabel
%21 = OpLoad %v4float %myHalf4
%22 = OpLoad %float %myHalf
%23 = OpVectorTimesScalar %v4float %21 %22
OpReturnValue %23
%main = OpFunction %v4float None %18
%19 = OpLabel
%20 = OpAccessChain %_ptr_Uniform_v4float %10 %int_1
%24 = OpLoad %v4float %20
%25 = OpAccessChain %_ptr_Uniform_float %10 %int_0
%28 = OpLoad %float %25
%29 = OpVectorTimesScalar %v4float %24 %28
OpReturnValue %29
OpFunctionEnd
1 error

View File

@ -1,10 +1,3 @@
### Compilation failed:
error: SPIR-V validation error: Uniform OpVariable <id> '8[%zoom]' has illegal type.
From Vulkan spec, section 14.5.2:
Variables identified with the Uniform storage class are used to access transparent buffer backed resources. Such variables must be typed as OpTypeStruct, or an array of this type
%zoom = OpVariable %_ptr_Uniform_float Uniform
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
@ -12,47 +5,54 @@ OpEntryPoint Vertex %main "main" %3
OpName %sk_PerVertex "sk_PerVertex"
OpMemberName %sk_PerVertex 0 "sk_Position"
OpMemberName %sk_PerVertex 1 "sk_PointSize"
OpName %zoom "zoom"
OpName %_UniformBuffer "_UniformBuffer"
OpMemberName %_UniformBuffer 0 "zoom"
OpName %main "main"
OpMemberDecorate %sk_PerVertex 0 BuiltIn Position
OpMemberDecorate %sk_PerVertex 1 BuiltIn PointSize
OpDecorate %sk_PerVertex Block
OpDecorate %zoom RelaxedPrecision
OpDecorate %zoom DescriptorSet 0
OpDecorate %19 RelaxedPrecision
OpDecorate %26 RelaxedPrecision
OpMemberDecorate %_UniformBuffer 0 DescriptorSet 0
OpMemberDecorate %_UniformBuffer 0 Offset 0
OpMemberDecorate %_UniformBuffer 0 RelaxedPrecision
OpDecorate %_UniformBuffer Block
OpDecorate %8 Binding 0
OpDecorate %8 DescriptorSet 0
OpDecorate %22 RelaxedPrecision
OpDecorate %30 RelaxedPrecision
%float = OpTypeFloat 32
%v4float = OpTypeVector %float 4
%sk_PerVertex = OpTypeStruct %v4float %float
%_ptr_Output_sk_PerVertex = OpTypePointer Output %sk_PerVertex
%3 = OpVariable %_ptr_Output_sk_PerVertex Output
%_ptr_Uniform_float = OpTypePointer Uniform %float
%zoom = OpVariable %_ptr_Uniform_float Uniform
%_UniformBuffer = OpTypeStruct %float
%_ptr_Uniform__UniformBuffer = OpTypePointer Uniform %_UniformBuffer
%8 = OpVariable %_ptr_Uniform__UniformBuffer Uniform
%void = OpTypeVoid
%11 = OpTypeFunction %void
%12 = OpTypeFunction %void
%float_1 = OpConstant %float 1
%14 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%15 = OpConstantComposite %v4float %float_1 %float_1 %float_1 %float_1
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_ptr_Uniform_float = OpTypePointer Uniform %float
%bool = OpTypeBool
%main = OpFunction %void None %11
%12 = OpLabel
%17 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %17 %14
%19 = OpLoad %float %zoom
%20 = OpFOrdEqual %bool %19 %float_1
OpSelectionMerge %23 None
OpBranchConditional %20 %22 %23
%22 = OpLabel
%main = OpFunction %void None %12
%13 = OpLabel
%18 = OpAccessChain %_ptr_Output_v4float %3 %int_0
OpStore %18 %15
%20 = OpAccessChain %_ptr_Uniform_float %8 %int_0
%22 = OpLoad %float %20
%23 = OpFOrdEqual %bool %22 %float_1
OpSelectionMerge %26 None
OpBranchConditional %23 %25 %26
%25 = OpLabel
OpReturn
%23 = OpLabel
%24 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%25 = OpLoad %v4float %24
%26 = OpLoad %float %zoom
%27 = OpVectorTimesScalar %v4float %25 %26
OpStore %24 %27
%26 = OpLabel
%27 = OpAccessChain %_ptr_Output_v4float %3 %int_0
%28 = OpLoad %v4float %27
%29 = OpAccessChain %_ptr_Uniform_float %8 %int_0
%30 = OpLoad %float %29
%31 = OpVectorTimesScalar %v4float %28 %30
OpStore %27 %31
OpReturn
OpFunctionEnd
1 error