Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tools/clang/lib/SPIRV/PervertexInputVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ int PervertexInputVisitor::appendIndexZeroAt(
///< treated as nointerpolated too.
bool PervertexInputVisitor::expandNointerpVarAndParam(
SpirvInstruction *spvInst) {
// If the spirv type has no AST type (hybrid struct for ex), no need to expand
// it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why there is no need to expand it?

if (!spvInst->hasAstResultType())
return true;

QualType type = spvInst->getAstResultType();
bool isExpanded = false;
auto typePtr = type.getTypePtr();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// RUN: %dxc -T ps_6_0 -E main -fcgl %s -spirv | FileCheck %s

struct PSInput
{
float4 position : SV_POSITION;
nointerpolation float3 color : COLOR;
};

cbuffer constants : register(b0)
{
float4 g_constants;
}

float4 main(PSInput input) : SV_TARGET
{
uint cmp = (uint)(g_constants[0]);

float colorAtV0 = GetAttributeAtVertex(input.color, 0)[cmp];
float colorAtV1 = GetAttributeAtVertex(input.color, 1)[cmp];
float colorAtV2 = GetAttributeAtVertex(input.color, 2)[cmp];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add checks to make sure the correct values are extracted from the input?


return float4(colorAtV0, colorAtV1, colorAtV2, 0);
}

// CHECK: OpDecorate [[var:%[a-zA-Z0-9_]+]] Flat
// CHECK: OpDecorate [[var]] PerVertexKHR

// CHECK: [[array:%[a-zA-Z0-9_]+]] = OpTypeArray %v3float %uint_3
// CHECK: [[type:%[a-zA-Z0-9_]+]] = OpTypePointer Input [[array]]
// CHECK: [[var]] = OpVariable [[type]] Input